osg Node节点透明度

发布时间 2023-12-23 00:59:54作者: 西北逍遥

osg Node节点透明度

 

osg::ref_ptr<osg::StateSet> stateState = north_wall_geode->getOrCreateStateSet();
stateState->setMode(GL_BLEND, osg::StateAttribute::ON);
stateState->setMode(GL_DEPTH_TEST, osg::StateAttribute::ON);
stateState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);

stateState->setAttributeAndModes(wall_material2, osg::StateAttribute::ON);

osg::ref_ptr<osg::BlendColor> blendColor = new osg::BlendColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.0f));
osg::ref_ptr<osg::BlendFunc> blendFunc = new osg::BlendFunc();

stateState->setAttributeAndModes(blendFunc, osg::StateAttribute::ON);
stateState->setAttributeAndModes(blendColor, osg::StateAttribute::ON);

blendFunc->setSource(osg::BlendFunc::CONSTANT_ALPHA);
blendFunc->setDestination(osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA);

blendColor->setConstantColor(osg::Vec4(1.0f, 1.0f, 1.0f, 0.999f));

 

 

 

 

###################