gl_FragCoord

Thanks in advance for any help…

Within a fragment program, what is the range of gl_FragCoord.x,gl_FragCoord.y, and gl_FragCoord.z?

Are they simply window coordinates or do they vary from 0 to 1?

The spec states:
The variable gl_FragCoord is available as a read-only variable from within fragment shaders and it holds the window relative coordinates x, y, z, and 1/w values for the fragment. This value is the result of the fixed functionality that interpolates primitives after vertex processing to generate fragments. The z component is the depth value that would be used for the fragment’s depth if a shader contained no writes to gl_FragDepth. This is useful for invariance if a shader conditionally computes gl_FragDepth but otherwise wants the fixed functionality fragment depth.

Within a fragment program, what is the range of gl_FragCoord.x,gl_FragCoord.y, and gl_FragCoord.z?
Are they simply window coordinates or do they vary from 0 to 1?
i know gl_FragCoord.z is from 0->1
for the other two it would be simple to find out just use glFragColor = vec4( gl_FragCoord.x,gl_FragCoord.y,1,1);

or
glFragColor = vec4( gl_FragCoord.x/100.0,gl_FragCoord.y/100.0,1,1);

and draw a few primatives

x and y are absolute window-positions (1…width, 1…height). Very usefull, when using rectangle-textures for post-processing effects :slight_smile:

Jan.

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