   if (nextFragmentReadStatus)
   {
     finalColor = blend(finalColor, nextFragment.color);
-    if (finalColor.a > alphaThresholdForDepth &&
-        gl_FragDepth == DEPTH_NOT_SET)
+    if (finalColor.a > alphaThresholdForDepth)
     {
       setDepthFor(nextFragment.eyePos);
     }

}

vec4 calculateColorOfVolumes(in int activeObjects, in int activeObjectCount,
    in vec4 segmentStartPos_eye, in vec4 endPos_eye, in vec4 fragmentColor, inout float depth)
{
  float segmentTextureLength  = calculateSegmentTextureLength(activeObjectCount,
      activeObjects, segmentStartPos_eye, endPos_eye);

  return ndcPos / ndcPos.w;
}

void setDepthFor(in vec4 positionInEyeSpace)
{
  if (gl_FragDepth != DEPTH_NOT_SET)
    return;

  vec4 ndcPos = fromEyeToNdcSpace(positionInEyeSpace);
  float depth = 0.5f * ndcPos.z + 0.5f;
  gl_FragDepth = depth;
}

void setColorForLayer(int layerIndex, vec4 color)
