Hi, I have a situation where I have Geodes with multiple parents. This means that the Drawables in the scenegraph might be rendered multiple times with different transforms depending on the node path to the root. The problem is that I need to be able to set a unique set of shader uniforms for the different rendered instancies of the same Drawable. What I want to do is to test the bounding sphere of the instance against that of the lights in the scene and set the uniforms based on this test. We do not use osg::Lights since we do not have to support fixed function pipeline, and the lights are stored in a separate datastructure in world space since light calculations is done in world space in the shaders.
An idea that I have is to add a drawcallback to the Drawable. In the callback I use RenderInfo::getState to retrieve the state for that instance. State::getInitialInverseMatrix combined with State::worldViewMatrix would give me the world matrix. The world matrix is used to transform the bounding sphere of the drawable and it can then be used for intersection tests. Im not really sure how to set the uniforms at this stage though. As I understand (from stepping trough the code) it is to late to change/add a stateset. I suppose that it would be possible to inject some OpenGL code, but this make me think that there might be a better solution. Is there a better way of achieving what I want than the idea i outlined above? By the way: What does "initial" means in State::getInitialInverseMatrix)? /Andreas Lindmark
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org