0

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

Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
  • 1
    Why do you think that the returned values are incorrect? Do you want the actual distance from the camera using the depth value? This depends on your projection matrix. You need to add how you initialize this matrix. – Nico Schertler Mar 03 '14 at 18:06
  • Why do you need `depth_bias` and `depth_scale` ? – Kromster Mar 04 '14 at 05:29
  • if i will have the real value of them , i can do a convertion and accept the absolute distance of the depth buffer – user3375217 Mar 04 '14 at 05:38
  • You don't need bias/scale to convert. Knowing Near/Far is enough - see in my answer. – Kromster Mar 04 '14 at 05:45
  • This looks like a similar question: http://stackoverflow.com/questions/6652253/getting-the-true-z-value-from-the-depth-buffer – Kromster Mar 04 '14 at 05:47

1 Answers1

0
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
Kromster
  • 7,181
  • 7
  • 63
  • 111
  • Your question is put like you already have that value. If not - you should get it. For example by reading from depth buffer. Perhaps you should ask a different question separately - "How to get Depth Buffer value?" – Kromster Mar 04 '14 at 07:09