I figured it out, I think it was due to my linearization of the z-buffer
values.
This is the right way to compute it, and it works for me:
Code:
float z, z_b, z_n=0;
for(int j=winH-1; j>=0; j--)
{
for(int k=0; k<winW; k++)
{
//compute real depth value in meters from the
normalized z-buffer [0..1] values
//z-buffer values are non-linear so have to
apply transformation to linearize the distance in world-space coordinates
z_b=((float*)image->data(k,j))[0];
z_n=2.0*z_b-1.0;
z=2.0 * zNear * zFar / (zFar + zNear - z_n *
(zFar - zNear));
}
}
Thanks for your help, Sergey!
Andrey
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50320#50320
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org