I have a OpenGL program using a Z buffer for hidden surface removal with a Cg vertex and fragment shader. In the fragment shader, I added some code to pass the fragment depth, ex:
…
OUT.color = IN.color;
OUT.depth = IN.depth;
return OUT;
}
When I ran the code, the Z buffer acted as disabled. When I do not pass the depth, the resultant image is correct. When I pass the depth, did I effectively disable Z buffering?
In the Cg book it says if I do not overwrite the DEPTH the fragment shader just passes the depth value through.
Is there a away using single pass rendering that the fragment shader can access the pixel color and depth stored in the frame buffer to implements its own blending? Or is the alpha blending a pure hardware implementation so it cannot be done?
Thanks,
Aaron