Hi Andreas,
Andreas Lindmark schrieb:
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?
You could add the position dependend StateSet directly to the Transforms
(in osg every osg::Node can have its own StateSet). You could do this
in an updateCallback.
By the way: What does "initial" means in State::getInitialInverseMatrix)?
/Andreas Lindmark
Regards,
Peter Hrenka
--
Vorstand/Board of Management:
Dr. Bernd Finkbeiner, Dr. Florian Geyer,
Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech
Vorsitzender des Aufsichtsrats/
Chairman of the Supervisory Board:
Prof. Dr. Hanns Ruder
Sitz/Registered Office: Tuebingen
Registergericht/Registration Court: Stuttgart
Registernummer/Commercial Register No.: HRB 382196
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org