Not logged in, Join Here! or Log In Below:  
News Articles Search    

 Home / 3D Theory & Graphics / Shadow mapping with multiple lights Account Manager
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.

April 04, 2005, 06:02 AM


How would you go about implementing shadow mapping with multiple lights? Would each light have its own shadow map and would the scene really need to be rendered as many times as there are lights or is it possible to compress the different shadowmaps in order to obtain some kind of union of the shadow maps, which can be used in the rendering pass?


April 04, 2005, 06:21 AM

As far as I know, you need to render the scene for each light. When it comes to actually using the shadow map, you can combine lights at the expense of complexity in your shader.

If you're dealing with point lights, that's up to 6 renders per light too. :(

Still, most lights are static and the reciever geometry is often static too (or at least parts of it are) so there are optimizations to be had.



April 04, 2005, 11:23 AM

In theory it's possible to render multiple lights with shadow maps in a single pass, you just need to render all the shadow maps beforehand and then write a pixel shader(s) which can do multiple light computations and access multiple shadow maps in a single invocation.

But in practice it seems like this would be a real pain, especially if you need to handle different types of lights. A lot of people do just re-render the scene with different lighting parameters for each light. To do this, it's good to Z fill the scene first, and then render each light additively to the frame buffer.

Some engines which have less complicated shadow systems (Far Cry, for example) do use pregenerated shader programs which handle different combinations of lights.

This thread contains 3 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.