Ok, I am writing a block of code to turn on the 4-5 lights that are closest to the viewer, in my particular scene. This way as the viewer moves from place to place, only x number of lights have to be on at a time. Ok my quesion is, would it be better to only turn on the lights that are within my viewing frustum, or the 4 closest lights to my player? I am not sure if turning out a light that is not in my viewing frustum will be noticable or not? I mean if its out side the frustum, does it still effect the polys that are inside the frustum??
You should not disable a light just because it’s outside the view frustum. A light outside the frustum still affects your primitives. A very bright light just outside the frustum will contribute quite a lot to primitives very close to that light, but still inside the frustum.
And saying that you should enable the 4 closest lights is not entirely the best either. You should go for the 4 light that affects the most to that particular object.
For example, say you have 4 very bright lights 5 units away from your object, and 4 almost dark lights 3 units away from the object. Then you probably wants to enable the four brighter lights, since they affect the object more than the four closest.
That assumes, of course, that you use attenuation, so a light fades over distance. Otherwise it won’t work very well.
How about culling lights using bounding spheres… if each light has an attenuation distance, use this as the radius of the bounding sphere… test this for intersection with the view frustum, and it will guarantee that any light that has a visible effect on your scene will pass. Then just enable the closest X of these…
Or better yet, do as Bob mentioned, and enable the lights with the largest attenuation distance. Yet another approach is to enable the closest (or largest) lights per object (or batch of polygons)… but remember, only if their bounding sphere lies within the view frustum
[This message has been edited by BadMmonkey (edited 06-17-2002).]
This old Mark Kilgard demo may interest you.
If you don’t look at the ceiling of your room, does the light switch off? No, of course not, because else you would all time sit in the darkness . The frustum makes only sense for visibility tests. I don’t know, if your lights are range limited or not, but if so it’s really the most senseful thing to show the 5 ones which with theirs range get most close to the observer (you). But anyway… where for do you need 5 lights? I hope you know, how expensive that amount of lights is. I have in general never more than 3 lights and this only in extreme cases. Except everything in your scene is something moving lightmaps are the far better solution in general… already because of the matter that you get the shadows with them for free.