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); osg::ref_ptr<osg::Program> program = new osg::Program; osg::ref_ptr<osg::Shader> vertShader = new osg::Shader(osg::Shader::VERTEX); vertShader->loadShaderSourceFromFile("shaders/testVert.glsl"); program->addShader(vertShader); osg::ref_ptr<osg::Shader> fragShader = new osg::Shader(osg::Shader::FRAGMENT); fragShader->loadShaderSourceFromFile("shaders/testFrag.glsl"); program->addShader(fragShader); 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); I am obviously missing something. I tried switching which texture was on the geode and the drawable just to make sure it wasn't a problem with the texture itself. There was no issue in switching it. Thank you for looking at this. Karl
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org