"warning C7506: OpenGL does not define the global variable gl_FragDepth"

I want to use the depth to set fragment color…

I have tried

gl_FragColor = vec4(gl_FragDepth, 0.0, 0.0, 1.0);

but when I run my app, I get the following:

“warning C7506: OpenGL does not define the global variable gl_FragDepth”

I thought gl_FragDepth was a valid variable…

And your hardware and driver is… ?

gl_FragDepth is write-only.

i believe gl_FragDepth is what u write the output depth value u want to
if u wanna access the current depth value (interpoltaed from the vs) use gl_FragCoord.z

A little correction:

gl_FragDepth is write-only.

Well, you can read it, but only after you have written something into it.

Somewhat related to this, when I try to read from gl_FragCoord I get some weird flicker of death, nothing gets rendered and it seems as if the rendering context goes out of whack, glIntercept reveals no issues.

The rather startling thing is that another shader (not coded by me) that uses it in a far more complex manner works fine.

ATI radeon 9600 pro, and catalyst drivers that are no more than 2 months old, I’ll get some new ones to be sure.

Unfortunately, using catalyst 6.4 drivers don’t help. Can anyone confirm any strange behaviour when trying to read from gl_FragCoord (I can’t do anything at all with it)?

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