When you call glReadPixels() on the GL_DEPTH_COMPONENT, it returns values from 0.0 to 1.0. How can you rescale these depths into world space depths? How can you determine how much the depths have been scaled by? I thought 0.0 corresponded to the near-plane and 1.0 to the far-plane but this doesn’t seem to be correct.
I know one way to do it is to use gluUnProject() to get the world coordinate of the pixel, then take the distance from the world coordinate to the camera. But this is too slow since it calculates more information than I need.
Is there any simpler way?