See http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

The values in the Zbuffer is 1.0 to 0.0 ( all realworld  values are
transformed in to this )  but it is NOT linear 


Gordon
Product Manager 3d
__________________________________________________________
Gordon Tomlinson
Email  : gtomlinson @ overwatch.textron.com
__________________________________________________________


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Roland
Leitner
Sent: Monday, June 15, 2009 3:29 AM
To: [email protected]
Subject: [osg-users] Using the z Buffer

Hi folks,

I am using the z-Buffer in osg 2.4 and have problems getting reasonable
values. When the camera is about two meters away from any flat object
surface, I'll get the value 0.995, and when the camera  is about eight
meters away i'll get 0.997 from the z buffer. I have also tried to
transform the z value into a distance value, but the distance value
makes no sense! Below is my code!

Cheers, Roland

osgViewer::View* view = new osgViewer::View; viewer.addView(view);

view->setSceneData(root);
 
view->getCamera()->setProjectionMatrixAsPerspective(V_FoV_deg,V_FoV_deg/
H_FoV_deg,1,100);
view->getCamera()->setViewport(new osg::Viewport(traits->width/2,0, 64, 
view->48 )); getCamera()->setGraphicsContext(gc.get());

osg::Image* image = new osg::Image();
view->getCamera()->attach(osg::Camera::DEPTH_BUFFER,image);
        
image->allocateImage(64,48,1,GL_DEPTH_COMPONENT,GL_FLOAT);

float z;

while( !viewer.done() )
{
   viewer.frame();

    z = ((float*)pmdimage->data())[1];
    std::cout << "z value : " << z << std::endl; }

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=13976#13976





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to