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 > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

