       vec4 endPosCut_eye = segmentStartPos_eye + alpha * vec4(dir, 0);
       if (activeObjectCount > 0)
       {
-        float depth = DEPTH_NOT_SET;
         fragmentColor = calculateColorOfVolumes(activeObjects, activeObjectCount,
-            segmentStartPos_eye, endPosCut_eye, fragmentColor, depth);
+            segmentStartPos_eye, endPosCut_eye, fragmentColor);
         finalColor = finalColor + fragmentColor * (1.0f - finalColor.a);
-        if (depth != DEPTH_NOT_SET)
-          setDepth(depth);
       }
 
       setColorForLayer(layerIndex, finalColor);

  return ndcPos / ndcPos.w;
}

void setDepth(float depth)
{
  if (gl_FragDepth == DEPTH_NOT_SET)
    gl_FragDepth = depth;
}

void setDepthFor(in vec4 positionInEyeSpace)
{
  vec4 ndcPos = fromEyeToNdcSpace(positionInEyeSpace);
  setDepth(ndcPos.z);
}

void setColorForLayer(int layerIndex, vec4 color)


    if (activeObjectCount > 0)
    {
      fragmentColor = calculateColorOfVolumes(activeObjects, activeObjectCount,
          segmentStartPos_eye, endPos_eye, fragmentColor);
      finalColor = finalColor + fragmentColor * (1.0f - finalColor.a);
    }
    else
    {
