Jump to content
  • Advertisement
Sign in to follow this  
Grumple

Depth buffer and multiple projections

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

I have a question regarding the depth buffer and near/far clip planes. If I define an ortho projection with a certain near and far clip plane, do some rendering, then define a new ortho projection with a different near and far clip plane and do some further rendering, what happens with the depth buffer? I am under the impression that the depth buffer is by default '1.0' deep, and that represents the range of nearplane->farplane in the viewport. But if the near and far planes change within a single render (i.e without clearing depth buffer between ortho's), what happens to the depth range, etc? Would it be that something half way between near and far planes in ortho projection one gets the same depth buffer value as something half-way between the near and far planes as ortho projection two? for example, would the following be true (all based from 0.0)?: ortho 1: near = 10.0, far = 20.0, render depth = 15.0, depth buffer depth = 0.5 ortho 2: near = 6.0, far = 7.0, render depth = 6.5, depth buffer depth = 0.5 Cheers!

Share this post


Link to post
Share on other sites
Advertisement
The orthographic projection maps the Z-value linear between the near and the far clipping plane. So, if something is exactly in the middle between these two it will get the depth value of 0.5. The both of your examples are correct.

One should remember that the points multiplied by the orthographic projection matrix have their depth values within the range of -1 to 1. However these values get again mapped to (0,1) before being passed further to the depth buffer.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!