Return to Snippet

Revision: 25487
at March 31, 2010 15:13 by vorp


Initial Code
// Enable blending, select transparent bin.
stateSet->setMode( GL_BLEND, osg::StateAttribute::ON );
stateSet->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );

// Enable depth test so that an opaque polygon will occlude a transparent one behind it.
stateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );

// Conversely, disable writing to depth buffer so that
// a transparent polygon will allow polygons behind it to shine thru.
// OSG renders transparent polygons after opaque ones.
osg::Depth* depth = new osg::Depth;
depth->setWriteMask( false );
stateSet->setAttributeAndModes( depth, osg::StateAttribute::ON );

// Disable conflicting modes.
stateSet->setMode( GL_LIGHTING, osg::StateAttribute::OFF );

Initial URL


Initial Description
For setting objects to be transparent

Initial Title
OSG transparency

Initial Tags


Initial Language
C++