Sure, for each object just enable the 8 lights that contribute most to it (you could do this for each vertex but that would be grossly inefficient). This means you take the lights intensity, distance from object and attenuation into account. You probably won’t even see the difference unless you have many tiny lights over a very large object and then you could just partition the object into smaller pieces.
But ofcourse then you’d have to constantly be changing the values of the light’s position back and forth within a single frame because, AFAIK, you only have the constants GL_LIGHT0-GL_LIGHT7 right? Or are there more than that? Assuming there are not, then if you needed, say, 16 lights, using the technique you described, wouldn’t you have to build a list of the most significant lights for each object every frame and then for each object change light position, color, etc.? Wouldn’t that be horribly slow? I’ve heard OpenGL state changes are very, very slow. It seems like I saw an article once about how to get past the limited number of lights in OpenGL… perhaps yours is the technique discussed in the article. I’d have to give it a try.
Why do you want to use more than 8 lights? What are you trying to do, have 30 cars all with headlights?
Also remember that on current cards (read: GeForce) triangle performance decreases pretty quickly when you add lots of lights, so if only say four lights conttribute to an object, culling the others might give a speedup. Secondly sorting your objects after material and lights (besides texture) is a good thing.
Well, I’ve got several missiles that cast light… also, I saw an nVidia demo with “unlimited lights” so it said and it looks fantastic! It’s a GeForce demo and it used TONS of lights. So I wonder how they did it… D3D? <and everyone’s eyes grow large and their hair stands on end>
Ahhh, casting an unlimited number of moving lights can be done with lightmaps. You just have to figure out which lightmaps to filter for each light (sometimes easier said than done ).
Originally posted by DFrey:
casting an unlimited number of moving lights can be done
If the number was unlimited, you would never reach the end of the rendering !
[This message has been edited by Eric (edited 02-14-2001).]