world space z coords from depth buffer

Hi!

is it possible to derive the world space z-coordinate of a point from its z value in the depth buffer? meaning that after rendering the scene, i wan to noe the value of the 3d coords of each point on the screen…

thanks!

There is no easy way to do it, the only functions in openGL that can do the conversion for you is gluProject/gluUnproject, as the values in the depth buffer is not linear it is a bit tricky to convert the values back to it’s true depth value by hand, at least there is no simple way that I know of.

Mikael

hmm… the problem is that the depth buffer values are quantized according to the precision of the zbuffer right? thats why the infomation is lost once we get to the depth buffer…

what about fragment programs? the values that it get are still before the quantization operation? if so is it possible to output the values during that stage via some textures?