I went a step further and added a second texture to the geode in texture unit 1. I now have a blue texture in unit 0 and a green texture in unit 1. If I add a uniform texSampler = new osg::Uniform("texture", 1) to the Drawable, then it changes the texture unit being used to 1 and now the green texture is used. So the state is being read in correctly. It just appears as if the texture itself never gets loaded into the texture unit. I also tried not loading a texture at all in the Geode and then I just get all black.
-----Original Message----- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Cary, Karl A. Sent: Saturday, August 06, 2011 11:22 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Loading different texture in child drawable than inparent geode I added that as well and it did nothing. I tried adding another uniform that I set to 0 in the geode in 1 in the drawable. The drawable is overriding the value. So it appears to be just an issue with the texture actually loading into the texture unit. -----Original Message----- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Ulrich Hertlein Sent: Saturday, August 06, 2011 7:56 AM To: OpenSceneGraph Users Subject: Re: [osg-users] Loading different texture in child drawable than in parent geode Hi Karl, On 6/08/11 3:53 , Cary, Karl A. wrote: > I have a geode that loads a shader. It loads up a texture that is meant to be > a default > texture. That geode then has many children drawables under it. The plan is > that each child > will have a different texture associated with it, but will otherwise be using > the same > shader and StateSet as the parent geode. If the child does not have a texture > associated > with it, it should use the one from the parent geode. If I put the shader in > the geode, > all geometry is drawn correctly. But if I try to load a different texture in > the child > drawable, the geode’s texture is used instead. Please help me figure out what > I am > missing. I’m starting to go bleary eyed! > > Here is the code that sets up the texture and shader in the geode (and this > works, the > texture loaded here shows up): > > stateSet = new osg::StateSet > texSampler = new osg::Uniform(“texture”, 0); > stateSet->addUniform(texSampler); > stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); > >... > stateSet->setAttribute(program); > stateSet->setAttributesAndModes(program.get(), osg::StateAttribute::ON); > this->setStateSet(stateSet); > > I then attempt to load a different texture in the drawable that is attached > to the above > geode. Here is the code I am attempting to use: > > stateSet = new osg::StateSet; > stateSet->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON | > osg::StateAttribute::PROTECTED); > > this->setStateSet(stateSet); From the code and your description I would expect this to work as well. Did you try to duplicate the Uniform in the Drawable StateSet? Maybe this makes a difference? Cheers, /ulrich _______________________________________________ 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 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org