uniform sampler2D myDepthPeelingZTexture;
uniform vec2 cViewportSize;
varying float rFarZ;

float ReadZ(float rZ)
{
  float dist = gl_TexCoord[0].y / (rZ - gl_TexCoord[0].x);
  return dist;
}

void main()
{
  float rDepthZ = ReadZ(texture2D(myDepthPeelingZTexture, (gl_FragCoord.xy + vec2(0.0)) * cViewportSize).r);
  if (rDepthZ >= rFarZ) discard;
  
  gl_FragColor = vec4(1.0);
}
