Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Z-coordinate in clip space (GLSL)

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
3 replies to this topic

#1 SamiHuutoniemi   Members   

259
Like
0Likes
Like

Posted 14 November 2012 - 10:15 AM

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?

#2 Brother Bob   Moderators   

10277
Like
2Likes
Like

Posted 14 November 2012 - 10:38 AM

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.

#3 SamiHuutoniemi   Members   

259
Like
0Likes
Like

Posted 14 November 2012 - 01:02 PM

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?

#4 Brother Bob   Moderators   

10277
Like
0Likes
Like

Posted 14 November 2012 - 01:12 PM

Correct. But as I said, I am not sure whether the screen coordinates are normalized or not; that is, before or after the viewport transform.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.