Hi everyone,

This is my first post to osg-users, and I'd like to thank everyone who has
contributed to OpenSceneGraph. I have found it to be indispensable.

Currently I am modifying a Delta3D-based engine to select the most
influential lights around an object, to allow our artists to place any
number of lights in a scene without being restrained by the usual cap of 8
lights.

The algorithm is as follows: Upon being added to the scene, LightSources
register themselves with the LightManager. Each lit object queries the
LightManager for the 4 most influential lights (based on proximity and light
intensity) during the Update traversal and assigns the appropriate shader to
the node, such as the 1 directional 1 spot 2 point light shader, the 2
directional 0 spot 1 point light shader, etc.

The final problem I have to solve is to figure out how to get the correct
lights into the correct order that the shaders will expect them in. I want
to be able to ignore the default light number of the 4 light sources I'm
using and be able to set them manually. However, this has proven difficult,
since many lights will need multiple different indices, and assigning this
in the update callback as I had originally planned would mean that every
change except the last one would be overwritten.

My first option is to write shaders with a list of uniforms for each light,
and set the uniforms in the expected order. I have shied away from this
approach for now to avoid bloated shaders, since GLSL has built-in uniforms
for OpenGL lights.

The second option, from what I've gathered, is to leverage
osgUtil::RenderStage. As I see it, I'm going to need to clone the lights
(managing them myself without adding them to the scene), re-number them
appropriately, and add them to their own RenderStage, which also contains
the lit object.

I've dug extensively through past threads looking for information on
RenderStage and selective lighting, but unfortunately I'm still somewhat
clueless as to how the back end of the rendering works as a whole. How do
RenderBins fit into this equation? Will I have to find a way to rip the lit
object out of the default RenderStage and throw it into mine? Is this even a
good approach, or is there a more elegant method I could use? Am I missing
the point completely?

Thanks in advance, everyone!

- Daniel Rowe
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to