osg模型透明代碼


 //關閉燈光
 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);
 //使用BlendFunc實現透明效果
 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.1));//第四個參數可用調節透明度
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章