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

  uvec2 ij = uvec2(pos.xy);

  gl_FragDepth = 1.0;

  uint maxAge = counters[Saddr(ij)];


  if (nextFragmentReadStatus)
  {
    finalColor = blend(finalColor, nextFragment.color);
    if (finalColor.a > alphaThresholdForDepth &&
        getDepth(layerIndex) == DEPTH_NOT_SET)
    {
      setPositionAndDepthFor(layerIndex, nextFragment.eyePos);
    }

    float endDistance = dot(nextFragment.eyePos, layerPlanes[layerIndex]);
    while (endDistance < 0 && layerIndex < planeCount)
    {
      setColorForLayer(layerIndex, finalColor);
      if (getDepth(layerIndex) == DEPTH_NOT_SET)
        setPositionNdc(layerIndex, vec4(1));
      finalColor = vec4(0);
      ++layerIndex;
      endDistance = dot(nextFragment.eyePos, layerPlanes[layerIndex]);
