|
我创建了一个平面,贴了个图在上面并且设置了透明材质
- osg::StateSet* stateset = geom->getOrCreateStateSet();
- stateset->setMode(GL_REPLACE,osg::StateAttribute::ON);
- stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
- osg::ref_ptr<osg::Material> material = new osg::Material;
- osg::ref_ptr<osg::TessellationHints> hints = new osg::TessellationHints;
- hints->setDetailRatio(0.5);
- material->setAmbient(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,1.0,1.0,1.0));
- material->setDiffuse(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,1.0,1.0,0.5));
- material->setSpecular(osg::Material::FRONT_AND_BACK,osg::Vec4(1.0,1.0,1.0,1.0));
- material->setShininess(osg::Material::FRONT_AND_BACK,6.0);
- geode->getOrCreateStateSet()->setAttributeAndModes(material,osg::StateAttribute::ON);
- geode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
- geode->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::ON);
- geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
复制代码
现在的问题是设置好法线,只有一个面能够清楚显示贴图,另一面很不清楚。
我尝试打开双面光照,似乎也没有效果。关闭光照的话就看不出透明了。
- geom->getOrCreateStateSet()->setMode( GL_LIGHT_MODEL_TWO_SIDE,osg::StateAttribute::ON| osg::StateAttribute::PROTECTED);
复制代码
请问应该如何才能在各个角度都能看清这个透明平面上的贴图呢? |
|