Hi Daniel, This topic is a surprisingly complex one as you're finding out. I think a couple of areas will need to be worked on to get a good final result.
First the rendering back end will have to tweaked so that objects are binned on light grouping they are associated with - this is where RenderStage comes in, or perhaps some of RenderStage's positional state functionality should be moved into RenderBin so you can use bin's instead of stages as this would be conceptually more appropriate for the type of rendering. Second area would be the management of the light source, or positional state if we are to generalise things. Right now the OSG has a direct 1:1 mapping between OpenGL light number and the osg::Light/glLight, this makes it easy to manage lights via GL_LIGHTING/GL_LIGHTi OpenGL modes, but for your type of application it does limit you when you want to dynamically allocate the light numbers. If you do want to dynamically allocate the light number then you'd have to use the osg::Light light number as an unique indetifier and then remap this to a real OpenGL light number use when passing lighting data to OpenGL, this remapping would have to be done for the GL_LIGHTi modes as well. Both of these changes are technically possible, and best done by changes to the core OSG itself, and I'm open to this, but I know roughly what some of the changes might need to be, actually implementing stuff will bring up lots of issues along the way. Once you do come out the other end the OSG itself will be more flexible w.r.t positional state which is obviously a good thing, but one should expect quite a bit of effort and head scratching before a solution pops out. Robert. On Mon, Oct 13, 2008 at 9:40 PM, Daniel Rowe <[EMAIL PROTECTED]> wrote: > 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 > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

