Hi everyone,

I am currently trying to set two textures on a geometry. To mix both textures I 
use a texEnvCombine with INTERPOLATE. That is how I did that:


Code:

//Initialize and Set the first texture.
osg::Texture2D* tex = new osg::Texture2D(osgDB::readImageFile("im1.jpg"));
tex->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR_MIPMAP_LINEAR);
tex->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, tex, 
osg::StateAttribute::ON);

//I use a texmat to repeat the texture ten times.
osg::TexMat* texmat = new osg::TexMat(osg::Matrix::scale(10,10,1.0));
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texmat);

//I configure my texEnvCombine.
osg::TexEnvCombine* texEnv = new osg::TexEnvCombine();
texEnv->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
texEnv->setSource0_RGB(osg::TexEnvCombine::PREVIOUS);
texEnv->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
texEnv->setSource1_RGB(osg::TexEnvCombine::TEXTURE);
texEnv->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
texEnv->setSource2_RGB(osg::TexEnvCombine::PRIMARY_COLOR);
texEnv->setOperand2_RGB(osg::TexEnvCombine::SRC_COLOR);
geode->getOrCreateStateSet()->setTextureAttribute(1, texEnv);

// And I set my second texture.
osg::Texture2D* tex2 = new osg::Texture2D(osgDB::readImageFile("im2.jpg"));
tex2->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR_MIPMAP_LINEAR);
tex2->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
tex2->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
tex2->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(1, tex2, 
osg::StateAttribute::ON);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(1, texmat);



With that code it works perfectly when I set GL_LIGHTING to OFF on the geode. 
But when I put the lights on, it has issues. In fact it is logical issues:
- My combine is set to INTERPOLATION, that's why the mixing will follow the 
function: Arg0*Arg2 + Arg1*(1 - Arg2)
- Here Arg0 is my first texture (PREVIOUS), Arg1 is my second one (TEXTURE) and 
the weight Arg2 is the PRIMARY_COLOR which is different at each place of my 
geometry.
- That's why it will return bad results when I have lights: the PRIMARY_COLOR 
will change with them (example: according to the function, all shadowed area 
will automatically set more of the second texture and vice versa.)

Which brings me to my question:
Is there a way to disable the light just for this combination ?

Thank you.

Guillaume[/code]

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=42518#42518





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to