Hi Steven, You're using the logical or operator "||" rather than bitwise or "|". If any parents of the camera are using the OVERRIDE flag on a shader, this can cause the problem you describe.
Mark Steven Powers wrote: > Let me know if you need more code than this. I can throw together a full > executable if it is needed. > > So far I've added a camera as a slave camera to the viewer. I have no > problems doing that. > > viewer->addSlave(_camera); > > Then when I add a shader to the slave camera: > > osg::ref_ptr<osg::StateSet> ss = _camera->getOrCreateStateSet(); > //shaders > osg::ref_ptr<osg::PolygonMode> mode = new osg::PolygonMode; > mode->setMode(osg::PolygonMode::FRONT_AND_BACK, > osg::PolygonMode::FILL); > osg::ref_ptr<osg::Program> program = new osg::Program; > program->setName( "SimpleShader"); > program->addShader( new osg::Shader( osg::Shader::VERTEX, > simpleVertexShaderSrc ) ); > program->addShader( new osg::Shader( osg::Shader::FRAGMENT, > simpleFragShaderSrc ) ); > > ss->addUniform(0); > ss->setAttributeAndModes( program.get(), osg::StateAttribute::ON || > osg::StateAttribute::OVERRIDE || osg::StateAttribute::PROTECTED); > ss->setAttributeAndModes( mode.get(), osg::StateAttribute::ON || > osg::StateAttribute::OVERRIDE || osg::StateAttribute::PROTECTED); > > > The shader does not seem to be invoked. If I use this same code and but add > the shader to the root node: > > //osg::ref_ptr<osg::StateSet> ss = _camera->getOrCreateStateSet(); > osg::ref_ptr<osg::StateSet> ss = _renderRoot->getOrCreateStateSet(); > > the shader works appropriately but is used on all cameras. I can throw > together a quick example program that will illustrate the problem if you need > more code than this. > > I have also tried removing the slave camera then re-adding it after I attach > the shader to it. > This same code works if I add the camera to the scene rather than adding it > as a slave camera. > > > > Thanks, > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

