Is it really impossible to have more than 8 ligths in open GL? It seems such a restriction… :-/
Erik
Is it really impossible to have more than 8 ligths in open GL? It seems such a restriction… :-/
Erik
If you need so many lights in order to achieve an effect - you probably want to start looking into shaders. In reality most games don’t use many lights and instead, even to this day, fake lighting through various texture tricks.
Thanks for your reply :).
Excuse my ignorance, but what’s a shader?
For example in Unreal, some weapons’s bullets are all lighting up. And I made some classes for Unreal once for effects like rain where each raindrop lights up, and ‘light fountains’. Looked really cool and really looked like light.
Nearly all the current crop of 3D FPS games use a lighting hack which is to project a coloured spotlight texture onto all the surfaces in range, and attenuate it according to distance by tweaking the alpha. The surface normal is not usually taken into account for these lights but you could try a hack and see what it looks like. The end result isn’t really lighting but it looks very pretty and it works on everything from a Voodoo1 and upwards.
If you draw all the lighting in your scene in a series of first passes using GL.ONE, GL.ONE, and then draw a single texturing pass using GL.DST_COLOR, GL.SRC_COLOR to blend them on top, you’ll get pretty much the effect of as many coloured lightsources as you want, at the expense of a lot of fill-rate. Sadly there isn’t really a great way to use multitexture for this.
The other alternative as Gregory suggests is to use a shader, which is a little machine-code style programming language available in OpenGL1.4 and on the very latest graphics cards - which means maybe about 1 in a 100 people will be able to see what you’ve done. For about the next 4-5 years or so. The number of lights you can incorporate in a shader is limited to 8 generally and may be less depending on the implementation but it’ll draw the whole surface with 8 lights and a texture (plus any other fancy stuff like bump mapping etc) in a single pass.
Cas 
However, if you really do want to use OpenGL’s lighting system but still need more than eight, there was a trick that one of the SGI demos pulled where they had a large number of “virtual” lights (data about lights in a big array I guess), and at run time they calculated which the eight closest were and set them up to be the OpenGL lights. Bit of a cheat, but it works! ;D
Naturally this will only work if your lights have a limited range of effect, you don’t have an obscene number of them, and they’re quite well spaced out. Quite limited, but if you fall in that camp it may be easier than the usual texture hacks. 
Also, the 8 light limit does not apply to the entire scene, but rather to each glBegin, glEnd pair. Furthermore, 8 is only the minimum number that implementations are required to provide for. In reality, an implementation may allow a higher number of lights. I’ve never checked the caps on the NVidia, ATI or other drivers though, so I have no hard numbers on this.
Here is an article I grabbed from Flipcode which talks about lightmapping. Once you read through what’s really being done you will say “OH! Wait that’s cheesy”, and it is … but it works surprisingly well. In fact it works well enough that unless you’re trying to do Doom3 style lighting, it looks more than sufficient.
Remember, large numbers of lights is slow and usually wasteful… especially when you can achieve the effect by either precomputing lighting at the vertex level (something done in Morrowind) or using lightmapping.