     }
   }
 
+  finalColor = clampColor(finalColor);
+
   if (position.w == POSITION_NOT_SET)
+  {
     position.w = 1;
-
-  finalColor = clampColor(finalColor);
-
-  outputColor = blend(finalColor, vec4(backgroundColor, 1.0));
-}
-
+    outputColor = blend(finalColor, vec4(backgroundColor, 1.0));
+    outputColor2 = vec4(backgroundColor, 1);
+  }
+  else
+  {
+    outputColor2 = blend(finalColor, vec4(backgroundColor, 1.0));
+  }
+}
+

    endPos_eye = nextFragmentReadStatus ?
      nextFragment.eyePos : segmentStartPos_eye;

    vec4 world = inverseViewMatrix * vec4(endPos_eye, 1);
    float dist = dot(world, farPlane);
    if (dist < 0)
    {
      endPos_eye = (viewMatrix * vec4(world.xyz - dist * farPlane.xyz, 1.0f)).xyz;
      nextFragmentReadStatus = false;
      // to prevent case of maxAge == 1 at the end
      age = ++maxAge;
    }

    if (activeObjectCount > 0)

    position.xyz = ndcPos.xyz;
    position.w = 1.0f;
  }
  else if (position2.w == POSITION_NOT_SET)
  {
    vec4 ndcPos = projectionMatrix * positionInEyeSpace;
    ndcPos = ndcPos / ndcPos.w;
    float depth = ndcPos.z;
    gl_FragDepth = depth;
    position2 = ndcPos;
  }
}

vec4 calculateSampleColor(in uint remainingActiveObjects, in int activeObjectCount,
