Forward rendering - multiple lights and shadows

How do you guys handle multiple shadow casting lights and forward rendering?

The most common way seems to be having multiple shadowmaps (one per light shadow casting light), and then rendering each model using each shadowmap.

However, that seems highly inefficient. I am wondering if there’s any other ways to tackle this. Anyone have any techniques that make this more efficient?

Do you limit your shadowcasting lights etc? If so, how many of each light type?

Thanks!

I do the same, but also give each of my lights a bounding box that represent its range of effect, such that any rendered object only takes into account those lights whose bounding box reaches its own. (Depending on the number of lights in your world, you might want to use a quadtree to store the bounding boxes.) This has had pretty good results for me.

@ed022 Thanks for the tip… I have been meaning to do that, but haven’t gotten around to it yet. Out of curiosity, how many lights of each type do you support, and how many are shadowcasting?

Admittedly, I haven’t messed with it in a couple years. But when I was playing around with it, I had eleven point lights in a room, all of which were shadow casting. Hypothetically should work with an unlimited number of lights.

Another similar trick that may or may not help is that you also don’t have to worry about any lights whose bounding boxes (which, again, surround their area of effect) are not within the view frustum. If you can’t see their effect, no sense in rendering with them.

So, maybe something like this:

foreach Light l within view frustum
    foreach Object o within l.BoundingBox
        render o to shadow map of l
foreach Object o within view frustum
    foreach Light l within view frustum
        if l.BoundingBox.Contains(o)
            render o lit by l

Once again, depending on the size of your scene, quadtrees/octrees are your friend here.