Hi, Everyone! Is there anybody can help to solve this problem. I tried to make geode node to be transparency in my application. A piece of my code is list below:
osg::StateSet* stateSet = geode->getOrCreateStateSet(); stateSet->setMode(GL_BLEND, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); osg::BlendFunc* blendFunc = dynamic_cast<osg::BlendFunc*>(stateSet->getAttribute(osg::StateAttribute::BLENDFUNC)); if (nullptr == blendFunc) { blendFunc = new osg::BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); stateSet->setAttribute(blendFunc, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); } else { blendFunc->setSource(GL_SRC_ALPHA); blendFunc->setDestination(GL_ONE_MINUS_SRC_ALPHA); } osg::Material* mat = dynamic_cast<osg::Material*>(stateSet->getAttribute(osg::StateAttribute::MATERIAL)); if (nullptr == mat) { mat = new osg::Material; stateSet->setAttribute(mat,osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); } mat->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(0.2f,0.2f,0.2f,0.3f)); mat->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(0.8f,0.8f,0.8f,0.3f)); mat->setTransparency(osg::Material::FRONT_AND_BACK, 0.4); osg::LightModel* lm = dynamic_cast<osg::LightModel *>(stateSet->getAttribute(osg::StateAttribute::LIGHTMODEL)); if (nullptr == lm) { lm = new osg::LightModel(); stateSet->setAttribute(lm,osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); } lm->setTwoSided(false); stateSet->setAttribute(lm, osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE); it seems like something is wrong as the transparency effect is miss-up. could anybody figure out what i missed and how to solve this problem. thanks very much for your help! Cheers, Yu ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76283#76283 Attachments: http://forum.openscenegraph.org//files/transparency_missup_209.png _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org