|
楼主 |
发表于 2009-12-1 09:19:45
|
显示全部楼层
我在一个点出设置两个纹理,但感觉并不是融合在一起,而是想在原来图上加了一个透明的玻璃似的。核心代码如下,
一个点两个纹理
vertices->push_back(osg::Vec3(px,-py,pz));
texcoords->push_back(osg::Vec2(i *1.0/ noSteps, 0));
texcoords1->push_back(osg::Vec2(i*1.0 / noSteps, 1));
polyGeom->setTexCoordArray(0,texcoords);
polyGeom->setTexCoordArray(1,texcoords1);
融合
osg::StateSet* stateset = polyGeom->getOrCreateStateSet();
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
stateset->setAttributeAndModes(new osg::BlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA),osg::StateAttribute::ON);
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);//帧缓存中拷贝出来的纹理
stateset->setTextureAttribute(0, new osg::TexEnv(osg::TexEnv::MODULATE),osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(1, testTexture,osg::StateAttribute::ON); //加载的一幅图
stateset->setTextureAttribute(1, new osg::TexEnv(osg::TexEnv::MODULATE),osg::StateAttribute::ON);
我想要的效果是两个纹理合成一幅,但是实际效果看上去两个纹理像是独立的 |
|