     float texCoord = texCoordExpandWidthAndShow.x;
     float expandDir = texCoordExpandWidthAndShow.y;
     float width = abs(texCoordExpandWidthAndShow.z) + 0.5;
-    bool usePrevDirection = texCoordExpandWidthAndShow.z < 0.0;
+    bool usePrev = texCoordExpandWidthAndShow.z < 0.0;
     float show = texCoordExpandWidthAndShow.w;
     
     vec4 p, prev, next;
-    vec4 prevDir;
-    vec4 nextDir;
-    
-    float segmentMagnitude;
-
     if (u_morphTime == 1.0)
     {
         p = vec4(czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz), 1.0);
         prev = vec4(czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz), 1.0);
         next = vec4(czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz), 1.0);
-        
-        segmentMagnitude = usePrevDirection ? length(prev - p) : length(next - p);
-        
-        prevDir = vec4(normalize(prev.xyz - p.xyz), 0.0);
-        nextDir = vec4(normalize(next.xyz - p.xyz), 0.0);
     }
     else if (u_morphTime == 0.0)
     {
         p = vec4(czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy), 1.0);
         prev = vec4(czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy), 1.0);
         next = vec4(czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy), 1.0);
-        
-        segmentMagnitude = usePrevDirection ? length(prev - p) : length(next - p);
-        
-        prevDir = vec4(normalize(prev.xyz - p.xyz), 0.0);
-        nextDir = vec4(normalize(next.xyz - p.xyz), 0.0);
     }
     else
     {

        return;
    }
    
    if (clipped)
    {
        prevDir = -nextDir;
    }
    
    float pixelSize = czm_pixelSizeInMeters * abs(positionEC.z);
    float expandWidth = width * 0.5;
    vec4 p0, p1;
    vec2 direction, nextWC, prevWC;
    
    if (czm_equalsEpsilon(prevDir, -nextDir, czm_epsilon3))
    {
        if (usePrevDirection || !clipped)
        {
            p1 = czm_eyeToWindowCoordinates(vec4(positionEC.xyz + nextEC.xyz * pixelSize, 1.0));
            nextWC = normalize(p1.xy - endPointWC.xy);
            direction = normalize(vec2(-nextWC.y, nextWC.x));
        }
        else
        {
            p0 = czm_eyeToWindowCoordinates(vec4(positionEC.xyz + prevEC.xyz * pixelSize, 1.0));
            prevWC = normalize(p0.xy - endPointWC.xy);
            direction = normalize(vec2(prevWC.y, -prevWC.x));
        }
    }
    else
    {
	    p0 = czm_eyeToWindowCoordinates(vec4(positionEC.xyz + prevEC.xyz * pixelSize, 1.0));
	    p1 = czm_eyeToWindowCoordinates(vec4(positionEC.xyz + nextEC.xyz * pixelSize, 1.0));
	    
	    prevWC = normalize(p0.xy - endPointWC.xy);
	    nextWC = normalize(p1.xy - endPointWC.xy);

    else if (endPoint0Distance < 0.0 && abs(denominator) > czm_epsilon7)
    {
        // t = (-plane distance - dot(plane normal, ray origin)) / dot(plane normal, ray direction)
        float t = (czm_currentFrustum.x + p0.z) / denominator;
        if (t < 0.0 || t > magnitude)
        {
            culledByNearPlane = true;
        }
        else
        {
            p0 = p0 + t * direction;
        }
    }
    
    positionWC = czm_eyeToWindowCoordinates(vec4(p0, 1.0));
}

void main() 
