   if (nextFragmentReadStatus)
   {
     finalColor = blend(finalColor, nextFragment.color);
-    if (position.w == POSITION_NOT_SET && nextFragment.color.w > alphaThresholdForDepth)
+    if (nextFragment.color.w > alphaThresholdForDepth)
     {
       setPositionAndDepth(nextFragment.eyePos);
     }


void setPositionAndDepth(vec4 positionInEyeSpace)
{
  vec4 ndcPos = projectionMatrix * positionInEyeSpace;
  ndcPos = ndcPos / ndcPos.w;
  float depth = ndcPos.z;
  gl_FragDepth = depth;
  position.xyz = ndcPos.xyz;
  position.w = 1.0f;
}

vec4 calculateSampleColor(in uint remainingActiveObjects, in int activeObjectCount,

    updateActiveObjects(objectId, activeObjects);
    int activeObjectCount = bitCount(activeObjects);

    if (objectId == 0 && fragmentColor.w > alphaThresholdForDepth)
    {
      setPositionAndDepth(currentFragment.eyePos);
    }
