[osg-users] stateSet texture attribute override

Riccardo Corsi riccardo.corsi at vrmmp.it
Tue Oct 2 09:36:47 PDT 2007

Hi all,

I'm after overriding some texture attributes in a hierarchy, following 
the osgmultitexture example, from within a "MyTextureSwitcher" node 
derived from osg::Group.
I basically want to load a new texture on layer 1 and try to mix/blend 
it with the other existing texture on the underlying geometries.
The hierarchy I have is the following:

  |-- geom1
  |-- geom2

Now if  I try to set the values on the MyTextureSwitcher StateSet, 
nothing happen (the new texture file is not even loaded).

If I change the same attributes on the MatrixTrasform instead, 
everything works nicely. The attributes I'm adding to override the other 
are as well highlighted in the attached image (thanks orhialcon).
Of course, I'd like to do everything in the MyTextureSwitcher stateset, 
as this is a node that I can add or remove to obtain different effects.

My code is:

    osg::StateSet* pSS = getChild(0)->getOrCreateStateSet(); // working 
    //osg::StateSet* pSS = getOrCreateStateSet(); // NOT working

    pSS->setTextureAttributeAndModes(1, mSwitchTex.get(), 
osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE);

    osg::TexEnv* texenv = new osg::TexEnv;

    pSS->setTextureAttributeAndModes(1,texenv, osg::StateAttribute::ON | 

Any clue why the second case is not working?

Thank you,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071002/0547d707/attachment-0002.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: comparison.png
Type: image/png
Size: 21109 bytes
Desc: not available
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20071002/0547d707/attachment-0002.png>

More information about the osg-users mailing list