I would like to get the depth buffer from my camera view for a 3D filtering application. I am currently using glReadPixels to get the depth component. Instead of the values โโ[0,1], I need the true values โโof the depth buffer or the true distance to the camera in world coordinates.
I tried converting depth values โโusing GL_DEPTH_BIAS and GL_DEPTH_SCALE, but that did not work.
glReadPixels(0, 0, width_, height_, GL_DEPTH_COMPONENT, GL_FLOAT, depth_buffer); glGetDoublev(GL_DEPTH_BIAS, &depth_bias); // Returns 0.0 glGetDoublev(GL_DEPTH_SCALE, &depth_scale); // Returns 1.0
I understand that this is similar to Getting the true z value from the depth buffer , but I would like to get the depth values โโin the main memory, not in the shader.
source share