Hi all,

I needed to change an HUD camera so that it would write into the depth
buffer.  To get it to work I had to do something that I don't understand.
I thought that a depth range of (0.,0.) and function of ALWAYS should cause
all subsequent rendering to write at the minimum depth value.  Doing so
would render lines OK but all filled polys and text went missing.  I found
that I had to open up the range a bit in order to see these too.

Does anyone have an idea why I needed to cheat the range here?

-Don



void Scene::createHUDCamera()
{
    _hud = new osg::Camera;
    _hud->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
    _hud->setClearMask( 0 );
    _hud->setRenderOrder(osg::Camera::POST_RENDER);

    _hud->getOrCreateStateSet()->setMode( GL_BLEND, osg::StateAttribute::ON );
    _hud->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF 
);

    // Instead of turing off hidden surface (depth test) use a depth func
    // to push the hud children in front of everything else.
    osg::Depth* depth = new osg::Depth;
    depth->setFunction( osg::Depth::ALWAYS );
    // setRange(.0, .0) should write all pixels at the minimum depth value.

    // depth->setRange( .0, .0 );   //### Loses all filled polys and text...

    depth->setRange( .0, .0001 );   // ...unless I do this. ###

_hud->getOrCreateStateSet()->setAttributeAndModes( depth, osg::StateAttribute::ON );

    _hud->setAllowEventFocus(false);

    _hudMembers = new osg::Group;
    _hud->addChild( _hudMembers.get() );
}

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to