Posted By

vorp on 03/31/10


Tagged

open osg graph scene


Versions (?)

OSG transparency


 / Published in: C++
 

For setting objects to be transparent

  1. // Enable blending, select transparent bin.
  2. stateSet->setMode( GL_BLEND, osg::StateAttribute::ON );
  3. stateSet->setRenderingHint( osg::StateSet::TRANSPARENT_BIN );
  4.  
  5. // Enable depth test so that an opaque polygon will occlude a transparent one behind it.
  6. stateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON );
  7.  
  8. // Conversely, disable writing to depth buffer so that
  9. // a transparent polygon will allow polygons behind it to shine thru.
  10. // OSG renders transparent polygons after opaque ones.
  11. osg::Depth* depth = new osg::Depth;
  12. depth->setWriteMask( false );
  13. stateSet->setAttributeAndModes( depth, osg::StateAttribute::ON );
  14.  
  15. // Disable conflicting modes.
  16. stateSet->setMode( GL_LIGHTING, osg::StateAttribute::OFF );

Report this snippet  

You need to login to post a comment.