Sign in to follow this  
Grumple

Depth buffer and multiple projections

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this