PDA

View Full Version : DepthRange. How it works?



Plutonium
09-07-2010, 10:49 PM
Hi! We specify far and near plane coordinates in glFrustum function. Calculation of z in pipeline depends on this parameters.
But it is not clear for me what DepthRange function do. It also specify far and near parameters. How they relates to far and near of glFrustum?

Dark Photon
09-08-2010, 06:30 AM
Hi! We specify far and near plane coordinates in glFrustum function. Calculation of z in pipeline depends on this parameters.
But it is not clear for me what DepthRange function do. It also specify far and near parameters. How they relates to far and near of glFrustum?
Think of it as the depth buffer values that equate to the near and far clip planes.

By default these are 0..1, meaning the near is the smallest depth buffer value (0) and far is the largest depth buffer value (1).

But you can change these to reserve parts of the depth buffer for other things. For instance, if you had two basic layers and you wanted to make sure one layer ended up on top, you could just render the furthest layer with depth range 0.5..1.0, and then render the nearest layer with depth range 0.0..0.5.