Easy way to get more than MAX_LIGHTS?

I just read an article on how to use shaders to achieve this, but that’s way beyond my current level of knowledge. Is there a relatively easy way to achieve this using the basic calls in the Red Book?

Yes ; you just render multiple time your geometry with different lighting condition and with additive blending (multiple passes).
So, in short, it gives the following pseudo code ;

  • Disable blending, set ambient lighting
  • Pass 1 : render geometry with MAX_LIGHTS set to your first MAX_LIGHTS lights,
  • Enable additive blending, disable ambient lighting
  • Pass 2 : render geometry with MAX_LIGHTS set tp the next MAX_LIGHTS lights,
  • Pass 3 : … and so on.

In practice, this algorithm is highly inefficient. Lighting computations are expensive and you should find a way to limit the number of lights influencing a model.
If you don’t want to spend too much time on this, I would suggest to use Java3D which does this automatically for you.

Multipass rendering with additive-blending maybe…

Are you sure you want more than MAX_LIGHTS on a single surface? Keep in mind that you’d need HDR rendering for that. 8bit precision can’t handle the contribution of so many lights, at least with decent quality.

I was just curious to tell you the truth. I had made a little test scene with more than 8 lights (sort of like torches) at various locations and just wondered how this was handled since it SEEMS like professional games have quite a few on at one time sometimes. I was simply hoping for an easy / cheap way to go, but it obviously isn’t going to happen.

Thanks for the answers, I certainly appreciate it.

Keith

Yeah, I suspected that. The optimal way to render such a scene would be to group areas by light and/or light count. If you have a copy of Doom 3 (or Quake 4?) available, there’s a console command that draws the scene colored, showing how it is actually split depending on the active lights.

One technique is to simply enable the closest MAX_LIGHTS lights to the object you are rendering, switching off the more distant (and therefore less significant) ones.

I spent a bit of time looking on the Web and found some descriptions of “virtualized lighting” techniques, so I believe I’ll try to code a Light class and LightManager to implement the idea. If I get something that seems to work OK in the near future I’ll put the code up here in case someone else might find it useful / interesting.