     }
 #endif
 
-    // Note the halfSize cannot be computed in JavaScript because it is sent via
-    // compressed vertex attributes that coerce it to an integer.
-    vec2 halfSize = imageSize * scale * czm_resolutionScale * 0.5;
-    halfSize *= ((direction * 2.0) - 1.0);
-
-    vec2 originTranslate = origin * abs(halfSize);
-
-#if defined(ROTATION) || defined(ALIGNED_AXIS)
-    if (validAlignedAxis || rotation != 0.0)
-    {
-        float angle = rotation;
-        if (validAlignedAxis)
+    mat2 rotationMatrix;
+    float mpp;
+
+    vec4 pEC1 = addScreenSpaceOffset(positionEC, imageSize, scale, vec2(0.0), origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
+    float t1 = getGlobeDepth(pEC1);
+
+    if (pEC1.z < t1)
+    {
+        vec4 pEC2 = addScreenSpaceOffset(positionEC, imageSize, scale, vec2(0.0, 1.0), origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
+        float t2 = getGlobeDepth(pEC2);
+
+        if (pEC2.z < t2 )
         {
-            vec4 projectedAlignedAxis = czm_modelViewProjection * vec4(alignedAxis, 0.0);
-            angle += sign(-projectedAlignedAxis.x) * acos( sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /
-                    (projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y) );
+            vec4 pEC3 = addScreenSpaceOffset(positionEC, imageSize, scale, vec2(1.0), origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
+            float t3 = getGlobeDepth(pEC3);
+            if (pEC3.z < t3)
+            {
+                positionEC.xyz = vec3(0.0);
+            }
         }
-
-        float cosTheta = cos(angle);
-        float sinTheta = sin(angle);
-        mat2 rotationMatrix = mat2(cosTheta, sinTheta, -sinTheta, cosTheta);
-        halfSize = rotationMatrix * halfSize;
-
-        #ifdef CLAMP_TO_GROUND
-            v_rotationMatrix = rotationMatrix;
-        #endif
-    }
-#endif
-
-    if (sizeInMeters)
-    {
-        positionEC.xy += halfSize;
-    }
-
-    float mpp = czm_metersPerPixel(positionEC);
-
-    if (!sizeInMeters)
-    {
-        originTranslate *= mpp;
-    }
-
-    positionEC.xy += originTranslate;
-    if (!sizeInMeters)
-    {
-        positionEC.xy += halfSize * mpp;
-    }
-
-    positionEC.xy += translate * mpp;
-    positionEC.xy += (pixelOffset * czm_resolutionScale) * mpp;
+    }
+
+    positionEC = addScreenSpaceOffset(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
     gl_Position = czm_projection * positionEC;
     v_textureCoordinates = textureCoordinates;
 

const float SHIFT_RIGHT2 = 1.0 / 4.0;
const float SHIFT_RIGHT1 = 1.0 / 2.0;

void main()
{
    // Modifying this shader may also require modifications to Billboard._computeScreenSpacePosition


#ifdef CLAMP_TO_GROUND
    float eyeDepth = positionEC.z;
#endif

    positionEC = czm_eyeOffset(positionEC, eyeOffset.xyz);
