/ Published in: C++
For setting objects to be transparent
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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 );