|
用osgOcean生成的海洋,我希望对它设置一下透明度,使得在海洋上方仍可以看到海岛延伸进海洋的一小部分。
可是我用了几种方法,海面透明度都没变化,有哪位大哥可以告知如何设置吗。
代码如下:
osg::StateSet* stateset=_oceanSurface->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF|osg::StateAttribute:ROTECTED);
stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::BlendColor *bc=new osg::BlendColor(osg::Vec4(1.0,1.0,1,0));
osg::BlendFunc *bf=new osg::BlendFunc();
stateset->setAttributeAndModes(bf,osg::StateAttribute::ON);
stateset->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.0,1.0,0.1)); |
|