I know I have asked a similar question before but I never got the answer I needed… how do I actually use more than eight lights. Doesn’t Open GL have a fixed number of lights you can use such as Light0 to Light7 so how do you use more than 8 lights…? If someone has used more than 8 lights in a given scene (all the more than eight lights being rendered at the same time)… please post some code.
We had the same question a week ago. Look down a bit.
more than 8 lights is not recomender, one light slow the FPS in a 23%, using dot3 lighting or lightmaps.
look with 8 light in my scene the FPS is 24.
Athon XP 1.4.
256 ddr 333.
thinking about this.
You can’t use more then eight light sources and you have been told that in your last message post, sorry it was not the answer your were looking for.
You where given the answer as to how to work around this by using light maps and get more then eight lights. This is how it is done in most 3D game engines.
Just do a search on “openGL light maps” for examples of how to do light maps in opengl.
Yes, it would be easy if you could do it with a simple openGL statment, and light maps take a little more work.
Originally posted by adityagaddam:
[b]I know I have asked a similar question before but I never got the answer I needed… how do I actually use more than eight lights. Doesn’t Open GL have a fixed number of lights you can use such as Light0 to Light7 so how do you use more than 8 lights…? If someone has used more than 8 lights in a given scene (all the more than eight lights being rendered at the same time)… please post some code.
[This message has been edited by nexusone (edited 10-28-2002).]
Using more than 8 lights isn’t recommended, but it CAN be done IF your implementation supports more than 8 lights. You check that using glGetInteger(GL_MAX_LIGHTS);
Now, I’m assuming your question is that, assuming your implementation supports more than 8 lights, what would you use for a constant in place of GL_LIGHT8, as the default constants only go to GL_LIGHT7. The answer is that you use GL_LIGHT0 + n, where n is the number of the light you want to use.
Again, using 8 lights isn’t generally recommended and you can find older discussions for how to do things like lightmaps, or only using the closest lights instead.
You could use more lights than your GL implementation supports with multipass rendering. In the first pass, enable the first eight lights and render as usual. In the second pass, enable the next eight lights, eliminate all terms that aren’t due to the light sources (fog, etc.), and render the scene again with additive blending. Sorry if I’m pointing out the obvious here.
yeah sorry I asked a similar question but I got several weird vague and contradicting answers and then someone said You definitely could so I went on through the rest of the code in my OpenGL book but found the preset names you have to use for the lights…
Thanks to all those replies… I will look into light maps…
P.S. Sorry once again
Another thing to consider is: WHY would you want to use more than 8 lights to light a single primitive?
If the answer is: just so I can set up all my lights and draw all my geometry in one go… then you have some optimisation work to do
You should consider grouping your primitives in such a way that each group is rendered with just the two or three relevant lights enabled. That will give you huge improvements in rendering speed with usually negligible loss of quality. YMMV of course.
Just my .02
thanks JML… would that be something like this…
initialize 8 lights at (x,y,z) (x,y,z)…
draw two cubes
initialize 8 lights at (x,y,z)…
draw two spheres
just pseudocode… but how can I tell opengl that I have rendered one group of primitives and am going to render the others with their own lights?
can you give me some pseudocode… or better… real code.
Just set the new light parameters and draw your objects. Just like the pseudocode you wrote.
oh ok… cool
so it is just like the binding of texture thing …