I use following code to set transparency:

osg::StateSet* state = root->getOrCreateStateSet();

state->setMode(GL_LIGHTING,osg::StateAttribute::OFF|osg::StateAttribute::PROTECTED);

state->setMode(GL_BLEND,osg::StateAttribute::ON);
state->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

osg::BlendColor* bc =new osg::BlendColor(osg::Vec4(1.0,1.0,1.0,0.0));
osg::BlendFunc*bf = new osg::BlendFunc();
state->setAttributeAndModes(bf,osg::StateAttribute::ON);
state->setAttributeAndModes(bc,osg::StateAttribute::ON);
bf->setSource(osg::BlendFunc::CONSTANT_ALPHA);
bf->setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);
bc->setConstantColor(osg::Vec4(1,1,1,0.5));

How to close transparency effect? I tried to use:
 state->setMode(GL_BLEND,osg::StateAttribute::OFF);
 state->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);

but it seems not work?
tks!

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

Reply via email to