• Advertisement
Sign in to follow this  

Z-coordinate in clip space (GLSL)

This topic is 1895 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Short question:

If I am in clip space (unless I've misunderstood, that's where I am after multiplying with the WorldViewProjection matrix), should I not be able to get the z-coordinate of any one pixel from the gl_FragCoord.z value?

Share this post


Link to post
Share on other sites
Advertisement
Your assumption is correct, you are in clip space after the modelview and the projection matrix, but that does not mean that the fragment coordinate is in clip space. The perspective division stage separates the two. The fragment coordinate is the window coordinate (not sure if it's the normalized or pixel coordinate though) of the fragment, and consequently the depth coordinate is effectively the depth buffer value.

Share this post


Link to post
Share on other sites

Your assumption is correct, you are in clip space after the modelview and the projection matrix, but that does not mean that the fragment coordinate is in clip space. The perspective division stage separates the two. The fragment coordinate is the window coordinate (not sure if it's the normalized or pixel coordinate though) of the fragment, and consequently the depth coordinate is effectively the depth buffer value.


So the gl_FragCoord.xy coordinates are screen coordinates? And by depth coordinate, may I assume you mean gl_FragCoord.z?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement