     }
   }
 
-
   setColorForLayer(layerIndex, finalColor);
+  if (getDepth(layerIndex) == 0)
+    setPositionNdc(layerIndex, vec4(1));
 
   for (++layerIndex; layerIndex < layerCount; ++layerIndex)
   {
     setColorForLayer(layerIndex, vec4(0));
-    setPositionNdc(layerIndex, vec4(0));
-  }
-}
-
+    setPositionNdc(layerIndex, vec4(1));
+  }
+}
+

void setPositionAndDepthFor(in int layerIndex, in vec4 positionInEyeSpace)
{
  vec4 ndcPos = fromEyeToNdcSpace(positionInEyeSpace);
  setPositionNdc(layerIndex, ndcPos);
  // TODO depth
}


    finalColor = blend(finalColor, nextFragment.color);
    if (nextFragment.color.a > alphaThresholdForDepth)
    {
      setPositionAndDepthFor(layerIndex, nextFragment.eyePos);
    }
    float endDistance = dot(nextFragment.eyePos, layerPlanes[layerIndex]);
    while (endDistance < 0 && layerIndex < planeCount)
