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 ));

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 );

 

 

 

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to