PDA

View Full Version : Extracting z coordinate from z buffer



camelo
07-07-2003, 08:58 AM
Is it possible to extract the z coordinate of a fragment from the information stored in the z buffer?

If yes, is this solution portable amongst desktop graphics accelerators and hi-end workstations?

Cheers,

camelo

Relic
07-07-2003, 11:44 PM
1.) Yes, glReadPixels with GL_DEPTH_COMPONENT.
2.) Yes, this is a standard OpenGL method. The performance may vary among implementations.

camelo
07-08-2003, 09:02 AM
Ok. So far so good. Now I need to convert the z information extracted from the z buffer back to camera space. How can I do that?

Thaks,

--camelo

camelo
07-08-2003, 09:08 AM
Found it...

gluUnProject

Thanks anyway.

Rog
07-08-2003, 09:09 AM
Does gluUnproject() do what you want?

Or have I missed the point.... http://www.opengl.org/discussion_boards/ubb/smile.gif

roffe
07-09-2003, 12:03 AM
Originally posted by camelo:
Now I need to convert the z information extracted from the z buffer back to camera space.

Haven't tried that myself, but I've heard people say that even though the data in the z-buffer are depth values it might not be that easy to map them back to camera space.To my knowledge OpenGL doesn't specify what format the depth values are stored in, it is implementation specific.