Archived

This topic is now archived and is closed to further replies.

How can I transform depth values into distances?

This topic is 5014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want my program to get that how far are the pixels from the frame buffer. When I get values from the depth buffer, these are clamped between (0,1), 0 for the frustum start, and 1 for the end. The problem is that I don''t know what type of function uses OpenGL for depth values , cause (for example) 0.5 isn''t at the half of the frustum.(Is it exponential???) However if I pass the depth and pixel-position values to gluUnproject and I calculate the distance from the returned point is OK, but it''s veeeery slow, specially for a viewport larger than 512X512, and I only need the distances, not their 3D position. So, my question is: How can I transform depth values into distances? Thanks!

Share this post


Link to post
Share on other sites
The Depth Buffer is exponential, higher concentration of values are near the camera, this is so you can have better depth handeling with the things you can see the best, the detail lessens as it approches the rear of your viewing frustrum.

As for converting such. I dont know.

"I seek knowledge and to help those who also seek it"

Share this post


Link to post
Share on other sites