                 innerRadiusSq, cylHalfLength, localPixelPos, localPixelRay,
                 localPrevJointAxis, localNextJointAxis,
                 innerIntersections, innerIntersectionCount, debugColor4);
-            //if (innerIntersectionCount == 2) {
-            if (false) {
-                #if true
+            if (innerIntersectionCount == 2) {
                 if (distance(fadeEndIntersections[0], innerIntersections[1])
                   < distance(fadeEndIntersections[0], innerIntersections[0])) {
                         vec3 temp = fadeEndIntersections[0];
                         fadeEndIntersections[0] = fadeEndIntersections[1];
                         fadeEndIntersections[1] = temp;
                     }
-                #endif
                 
                 innerContribution = distance(innerIntersections[0], innerIntersections[1]); // reuse pls
                 fadeContribution =
-                    linearFadeContribution(fadeEndIntersections[0], innerIntersections[1],
+                    linearFadeContribution(fadeEndIntersections[0], innerIntersections[0],
                                            innerRadius, fadeEndRadius)
-                  + linearFadeContribution(fadeEndIntersections[1], innerIntersections[0],
+                  + linearFadeContribution(fadeEndIntersections[1], innerIntersections[1],
                                            innerRadius, fadeEndRadius);
             } else {
                 fadeContribution

float nonLinearFadeContribution(vec3 fadeIntr1, vec3 fadeIntr2,
                                float rInner, float rFadeEnd)
{
    float intrDist = distance(fadeIntr1, fadeIntr2);
    vec3 diff = fadeIntr2 - fadeIntr1;
    vec3 pivot;
    pivot.xy = fadeIntr1.xy - dot(diff.xy, fadeIntr1.xy) * diff.xy / length(diff.xy);
    pivot.z = fadeIntr1.z + (pivot.x - fadeIntr1.x) / diff.x * diff.z;
    // TODO handle diff.x == 0
    
    return linearFadeContribution(fadeIntr1, pivot, rInner, rFadeEnd)

    vec3 nextJointPos = vec3(0, 0, halfLength);
 
    debugColor = vec4(0, 0, 0, 1);
    if (abs(localPixelRay.x) > 0.0000001 || abs(localPixelRay.y) > 0.0000001) {
        // view ray is not parallel to cylinder axis so it may intersect the sides
        // solve: (p_x + dir_x * t)^2 + (p_y + dir_y * t)^2 = r^2; in quadratic form:
        // (dir_x^2 + dir_y^2) * t^2 + [2(p_x * dir_x + py * dir_y)] * t
