What kind of values should gl_FragDepth be giving?

I would think this would return a float between 0 and 1, but it seems to always return 0. All I am trying to do is get the fragment depth for fog rendering.

The gl_FragDepth is output variable which is used to override depth of the fragment. The fragment depth calculated by hw is stored within gl_FragCoord.z

I thought ATI didn’t support gl_FragCoord.z.

Originally posted by Leadwerks:
I thought ATI didn’t support gl_FragCoord.z.
It does not have explicit hw support however the driver tries to emulate it using ordinary varying. It is possible that use of additional feature such as polygon offset (
see here ) will force it to sw emulation or that some drivers have buggy implementation.

If you do not wish to rely on the driver, you can calculate the depth in vertex shader and send it trough the varying manually.

Thank you.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.