Jason Beverage wrote:
Hi all,

I'm trying to figure out a way to modify layer opacity using TexEnvCombine that takes into account the underlying alpha channel of a texture.

Do you mean if unit 1's texture has transparency, you want that to show through to unit 0's texture?



The osgFX::MultiTextureControl does very close to what I'm looking to do, but doesn't take into account the fact that the underlying texture may contain transparency (like a road overlay).

From my understanding of texenvcombine, I can either use a constant color or SRC_ALPHA as an operand, but not a combination of both.

It sounds like you need three parameters combined (2 texture colors and a user-defined parameter), so your only hope is the INTERPOLATE mode for the alpha values (INTERPOLATE is the only combiner operation that takes three parameters). Try this:

tec->setSource0_RGB(osg::TexEnvCombine::TEXTURE0);
tec->setSource1_RGB(osg::TexEnvCombine::TEXTURE1);
tec->setCombine_RGB(osg::TexEnvCombine::MODULATE);

tec->setConstantColor(osg::Vec4(1.0, 1.0, 1.0, userDefinedAlpha));
tec->setSource0_Alpha(osg::TexEnvCombine::TEXTURE0);
tec->setSource1_Alpha(osg::TexEnvCombine::TEXTURE1);
tec->setSource2_Alpha(osg::TexEnvCombine::CONSTANT);
tec->setCombine_Alpha(osg::TexEnvCombine::INTERPOLATE);

I just made this up, so I have no idea if it will work or not. It might not be the only possibility, either, but it's all I can think of right now.

--"J"

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to