简体   繁体   中英

Absolute distance of depth buffer

1.How can i find the absolute distance of the depth buffer?

2.How can I calculate the real value of the depth_bias and depth_scale? I tried by the commends:

glGetDoublev(GL_DEPTH_BIAS,  &depth_bias);  // (Returns only 0.00)
glGetDoublev(GL_DEPTH_SCALE, &depth_scale); // (Returns only 1.0 )

In my code I declared this values- zNear, zFar. and I decide what value to give them so they are not const.so the distance is dependent in the ZFAR,ZNEAR and the depthBufferValue(change from pixel to pixel) –

Distance = NearClipPlane + DepthBufferValue * (FarClipPlane - NearClipPlane);

Near/Far clip planes values are used to construct projection matrices. You should be able to see them in your code. For example:

glOrtho(left, right, bottom, top, nearVal, farVal); // <-- Last two values here
gluPerspective(fovy, aspect, zNear, zFar); // <-- Last two values here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM