PDA

View Full Version : OpenGL Lighting...



Sephiroth
02-05-2002, 10:25 PM
Just curious, but how many lights does OpenGL allow? I have used several at ocne in my tiny test level and the dynamic lighting is GREAT (like on Unreal). Now I plan on allowing my game engine to progres to the state of an Unreal Engine clone, and for that I will need more than three lights at once. Is there a limit on OpenGL lights? If so, can I change it to a max value, say 512 or 1024? See some of the magic effects use lights also, so on a bigger level (say Nali Castle) I would need not only enough lights for all the torches, the sky, etc, but I would need at LEAST 128 free for magic spells and such that players and NPCs would be using on eachother.

JML
02-05-2002, 10:40 PM
OpenGL implementations are required to support at least 8 lights. This usually will suffice.
Since using multiple lights usually results in a dramatic decrease of performance, it is wise to use as few lights as possible while rendering your scenes.

You can query your OpenGL implementation with glGetIntegerv( GL_MAX_LIGHTS), which will give the maximum number of simultaneously active lights.

The trick is to reuse these available lights in such a way that only the relevant lights are enabled when drawing your primitives (for example, only activate the lights within a certain radius from the primitives).

Lots of lighting tricks can be simulated by using lightmaps or other texture-based solutions to imitate highlights/shadows on objects.

HTH

Jean-Marc