How should I implement more than 8 lights in OpenGL?
I would like to render unlimited amounts of lights efficiently.
So, whats the preferred method for doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Deferred shading.
In a nutshell you render your scene without any lights. Instead you store the normals and world positions along with the textured pixels into multiple frame-buffers (so called render targets). You can even do this in a single pass if you use a multiple render-target extension.
Once you have your buffers prepared you start to render a bunch of full-screen quads, each with a pixel shader program that reads out the normals and positions and computes the light for one or multiple light-sources.
Since light is additive you can render as much full-screen quads as you want and accumulate the light for as much light-sources as you want.
A final step does a composition between your light and the unlit textured frame-buffer.
That’s more or less the state-of-the-art way to do it. Getting fog and transparency working with such a system is a challenge though.