Hi Pavlos, I'm interested in this topic too. I haven't found the discussions in the archives, but I probably just haven't picked the right search keywords.
My problem is very similar to yours I think. I want to have a lot of lights in my scene that falloff completely after a reasonable distance and only apply 3 of them to each piece of geometry, probably choosing them based on proximity and/or brightness. I was thinking of only activating lights 0, 1, and 2 and applying a cull callback to all my geodes that would set different light positions and colors for each geode that doesn't get culled. The positions and colors would be chosen from a much larger pool of lights that I store in my own data structures outside of OpenGL and OSG. I haven't figured out if I would do this by setting parameters for OpenGL lights 0, 1, and 2, or by setting custom shader Uniforms. Or there might be a much better approach I haven't thought of. Anyway, I'd like to discuss this more or hear from anyone who has done this.... - Terry > Message: 3 > Date: Wed, 2 Jan 2008 16:42:37 +0000 > From: "Robert Osfield" <[EMAIL PROTECTED]> > Subject: Re: [osg-users] Selective lighting in OSG > To: "OpenSceneGraph Users" <[email protected]> > Message-ID: > <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1 > > Hi Pavlos, > > I'm afraid handling more than max number of OpenGL lights is awkward > in the OSG, it is possible but you'll need to learn quite a bit about > the internals of how the rendering back end is setup and traversed. > This topic has been discussed in the past on osg-users so have a bash > at going through the email archives. > > Robert. > > On Jan 2, 2008 4:13 PM, Pavlos Mavridis <[EMAIL PROTECTED]> wrote: > > Selective lighting in OSG > > > > Hello everyone, > > what is the best way to define a light that affects not the entire > > scenegraph, but only a part of it? > > > > For example I have a scene with many objects. Each one of them is lit by > > one light that is > > different from one object to another. So the number of lights can be > > greater than GL_MAX_LIGHTS, > > but since each object is lit only by one light, using opengl we could > > render the entire scene using > > only one hardware light (lets say GL_LIGHT0), by resetting its > > parameters per object. > > > > In the general case we can have more than one light per object and the > > lights can be > > turned on and off per frame. So, what is the best way to do this in OSG? > > > > I've tried passing the stateset of the sub-tree I want to light on a > > lighsource node using: > > lightsource->setStateSetModes(stateset,osg::StateAttribute::ON); > > but it doesn't work as expected. > > > > Also I've tried changing the stateset of the sub-tree I want to light > > directly, > > without using any lighsource nodes: > > stateset->setAttributeAndModes(light, osg::StateAttribute::ON); > > stateset->setMode( GL_LIGHT0 + num, osg::StateAttribute::ON ); > > to enable a light and > > stateset->setAttributeAndModes(light, osg::StateAttribute::OFF); > > to remove it. > > > > The last method seems to work when the number of lights is constant per > > frame, > > but it brakes when I try to dynamically turn on and off lights per > > frame. (perhaps > > because I have to manually enable/disable the corresponding opengl lights?) > > > > So, what is the best way to do this in OSG? > > > > Thanks in advance > > > > Pavlos Mavridis > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

