深度缓冲区的绝对距离

时间:2014-03-03 14:26:43

标签: c++ opengl zbuffer

1.如何找到深度缓冲区的绝对距离?

2.如何计算depth_bias和depth_scale的实际值? 我试过这个表彰:

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

在我的代码中,我声明了这个值 - zNear,zFar。我决定给它们什么值,所以它们不是const。所以距离取决于ZFAR,ZNEAR和depthBufferValue(从像素到像素的变化) -

1 个答案:

答案 0 :(得分:0)

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

近/远剪裁平面值用于构造投影矩阵。您应该能够在代码中看到它们。例如:

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