Hi Jason,

You're exactly right, if texture 1 has transparency, then I want texture 0
to show through no matter what.  Doing something like the following on unit
0 works great in that case, but I also want to add in another scaling factor
that will scale the alpha value of the texture from 0 to 1 to essentially
act as a slider for the opacity.  I'll keep hacking along, but I might need
to just stick with shaders.

        osg::TexEnvCombine* tec = new osg::TexEnvCombine;
        tec->setSource0_RGB(osg::TexEnvCombine::TEXTURE1);
        tec->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);

        tec->setSource1_RGB(osg::TexEnvCombine::TEXTURE0);
        tec->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);

        tec->setSource2_RGB(osg::TexEnvCombine::TEXTURE1);
        tec->setOperand2_RGB(osg::TexEnvCombine::SRC_ALPHA);

        tec->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);

        csn->getOrCreateStateSet()->setTextureAttribute(0, tec);

Thanks!

Jason

On Mon, Jun 8, 2009 at 8:23 PM, Jason Daly <jd...@ist.ucf.edu> wrote:

> 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
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to