[vtkusers] Z-buffer to Depth: formula
Wes Bethel
ewbethel at lbl.gov
Fri Dec 9 09:54:05 EST 2011
Check out the OpenGL vertex transformation web page:
http://www.opengl.org/wiki/Vertex_Transformation
In brief, you need to know the specifics of the view (camera) and any
world-coordinate transformations, along with the exact values for the
near/far clip plane, in order to compute, from a z-buffer value, a
depth-from-the-viewpoint (eye) in either eye or world coordinates. It is
likely these complexities/details that prevent someone from handing you
a chunk of code to compute it.
I've personally written code to do this in the past, but focused on
doing depth-from-viewpoint in eye coordinates to avoid the snake-pit of
world coordinate system transformations.
Your best bet is to look at the URL above so that you can construct the
conversion formula yourself given whatever your specific needs are.
HTH,
wes
On 12/9/11 6:39 AM, Dženan Zukić wrote:
> 0 corresponds to near clipping plane, and 1 corresponds to far clipping
> plane. If you know the distance of both you can do linear interpolation.
> Someone correct me if I am wrong.
>
> On Fri, Dec 9, 2011 at 07:41, Atul Kumar<sharmaatul11 at gmail.com> wrote:
>
>> Thank you so much David. I will try vtkRenderer::ViewToWorld().
>>
>> To Dev
>>
>> vtkRenderer::GetZBufferData() gives us the depth map values which ranges
>> from 0 to 1, so it is not the actual depth value at the pixels. To get the
>> actual depth at pixels we need to convert Z-buffer into actual depth
>> values. So, for this we need a conversion formula. I hope this makes it
>> clear.
>>
>> Regards,
>> Atul
>>
More information about the vtkusers
mailing list