   float endDistance = dot(endPos_eye, layerPlanes[layerIndex]);
   while (endDistance < 0)
   {
-    setPositionNdc(layerIndex, vec4(1));
+    setPositionNdcToEndValue(layerIndex);
     setColorForLayer(layerIndex, vec4(0));
     ++layerIndex;
     endDistance = dot(endPos_eye, layerPlanes[layerIndex]);


  setColorForLayer(layerIndex, finalColor);
  if (getDepth(layerIndex) == DEPTH_NOT_SET)
    setPositionNdc(layerIndex, vec4(1));

  for (++layerIndex; layerIndex < layerCount; ++layerIndex)
  {
    setColorForLayer(layerIndex, vec4(0));
    setPositionNdc(layerIndex, vec4(1));
  }
}


    {
      setColorForLayer(layerIndex, finalColor);
      if (getDepth(layerIndex) == DEPTH_NOT_SET)
        setPositionNdcToEndValue(layerIndex);

      finalColor = vec4(0);
      ++layerIndex;
