What do you mean by "TexEnvCombine::INTERPOLATE actually takes 3
arguments"?  Isn't INTERPOLATE an argument to the setCombine_RGB
function?  I must be missing something...


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Tim Moore
Sent: Wednesday, May 23, 2007 1:39 PM
To: osg users
Subject: Re: [osg-users] TexGenNode & TexEnvCombine

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Weitz, Andrew C. wrote:
> I tried a border color with an alpha of 0, but no luck.  When I use an
> alpha of 0 and enable GL_BLEND, the terrain surrounding my projected
> texture becomes invisible.  I tried playing with
> TexEnvCombine::setCombine_Alpha(),  however I haven't been able to get
> that to work either.  Am I on the right track here?
> 
TexEnvCombine::INTERPOLATE actually takes 3 arguments; you seem to have
left the interpolating value out. You can use the alpha channel of your
projected texture, including the border color's alpha, if you add

tec->setSource2_RGB(osg::TexEnvCombine::TEXTURE);
tec->setOperand2_RGB(osg::TexEnvCombine::ONE_MINUS_SRC_ALPHA);

To your TexEnvCombine attribute.  All untested of course :)

Tim

> Thanks,
> Andrew
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Donald
Tidrow
> Sent: Wednesday, May 23, 2007 11:17 AM
> To: osg users
> Subject: Re: [osg-users] TexGenNode & TexEnvCombine
> 
> On Tue, 22 May 2007, Weitz, Andrew C. wrote:
> 
>> Hi,
>>
>>
>>
>> I'm having transparency issues that I thought were solvable with a
>> TexEnvCombine.  However, I cannot figure out the solution.
>>
>>
>>
>> I have a scene in which I'm projecting a texture onto terrain that is
>> already textured.  The terrain is generated with the createBase()
>> function in the osgShadowTexture example.  I'm projecting another
>> texture onto that terrain via a TexGenNode.  My projected texture
only
>> encompasses a small portion of the entire terrain.
>>
>>
>>
>> I'd like to control the opacity of my projected texture.  I tried
> doing
>> so with a TexEnvCombine.  This seems to work correctly, except that
it
>> blends the textures on the entire terrain-not just the area where my
>> texture is projected.  The terrain surrounding the projection area
> gets
>> blended with my projected texture's border color.  This makes me
think
>> that a solution would be to make my projected texture's border
>> transparent.  However, I can't figure out how.  Relevant code is
>> below...
>>
>>
>>
>> Is there a way I can only control the opacity/blending only in the
> area
>> where my texture is projected?
>>
>>
>>
>> Thank you,
>>
>> Andrew
>>
>>
>>
>>
>>
>> // Create the terrain (this uses a texture unit of 0)
>>
>> osg::ref_ptr<osg::Geode> shadowed = createBase( osg::Vec3(0, 0, 0),
50
>> );
>>
>>
>>
>> // Create the TexGenNode
>>
>> osg::ref_ptr<osg::TexGenNode> texgenNode = new osg::TexGenNode;
>>
>> texgenNode->setTextureUnit( 1 );
>>
>> texgenNode->getTexGen()->setMode( osg::TexGen::EYE_LINEAR );
>>
>> texgenNode->getTexGen()->setPlanesFromMatrix( blah blah blah );
>>
>>
>>
>> // Create the decorator stateset with the projected texture
>>
>> osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
>>
>> texture->setInternalFormat( GL_RGB/*A*/ );
>>
>> texture->setWrap( osg::Texture2D::WRAP_S,
>> osg::Texture2D::CLAMP_TO_BORDER );
>>
>> texture->setWrap( osg::Texture2D::WRAP_T,
>> osg::Texture2D::CLAMP_TO_BORDER );
>>
>> texture->setBorderColor( osg::Vec4( 1.0, 0.0, 0.0, 1.0 ));
>>
> Try setting the border color to something transparent, ie.
> osg::Vec4( 1.0, 0.0, 0.0, 0.0 )
> 
>> stateset->setTextureAttributeAndModes( 1, texture.get(),
>> osg::StateAttribute::ON );
>>
>> stateset->setTextureMode( texture_unit, GL_TEXTURE_GEN_S,
>> osg::StateAttribute::ON );
>>
>> stateset->setTextureMode( texture_unit, GL_TEXTURE_GEN_T,
>> osg::StateAttribute::ON );
>>
>>
>>
>> // Create the TexEnvCombine
>>
>> osg::ref_ptr<osg::TexEnvCombine> tec = new osg::TexEnvCombine();
>>
>> tec->setCombine_RGB(osg::TexEnvCombine::INTERPOLATE);
>>
>> tec->setSource0_RGB(osg::TexEnvCombine::TEXTURE);
>>
>> tec->setSource1_RGB(osg::TexEnvCombine::PREVIOUS);
>>
>> tec->setOperand0_RGB(osg::TexEnvCombine::SRC_COLOR);
>>
>> tec->setOperand1_RGB(osg::TexEnvCombine::SRC_COLOR);
>>
>> tec->setConstantColor(osg::Vec4(0.5, 0.5, 0.5, 0.5 ));
>>
>> stateset->setTextureAttributeAndModes(1, tec.get(),
>> osg::StateAttribute::ON );
>>
>>
>>
>>
>>
>>
>>
>>
> 
> ---
> In October 1997, three computer lab staffers
> disappeared from the server room while debugging
> a mysterious router problem.
> 
> One year later, their packet logs were found...
> 
> 
>           The Blair Switch Project
> 
> --------------------
> |  Don Tidrow      |
> |  Vis-Sim Geek    |
> --------------------
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFGVKZseDhWHdXrDRURAp26AKC5MqqD8DRdLg2Cuc7bK8AFCF9/EQCgnnMx
54YDM8sdnCcISbBJlm0Cwb4=
=LcrM
-----END PGP SIGNATURE-----
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to