Jump to content
  • Advertisement
Sign in to follow this  
jerrycao_1985

OpenGL how is the depth range changed between NDC and depth buffer

This topic is 2026 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

hi everyone

 

It occurred to me that the depth value in NDC is between -1 and 1 , while the depth value in depth buffer is between 0 and 1.

 

So where did the change happened ?

 

And most importantly , why does OpenGL bother to make the range between -1 and 1, then change it to 0 and 1.

DX does it in a simpler way , range of depth is always between 0 and 1 after perspective divide by default.

Share this post


Link to post
Share on other sites
Advertisement

So where did the change happened ?

When the fragment processing (and sorting with depth test enabled) happens. see glDepthRange().

Share this post


Link to post
Share on other sites

according to the document of glDepthRange 

It's during transformation between NDC and window coordinate , much earlier than fragment processing.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!