Q:

Shadowmapping theory question

I think im on good way to grasp the complete concept of simple hard-edged shadowmapping!
The thing i find the hardest to grasp though is about the individual shadow-render for each light...
Since the example shadowmap-textures i have looked at are normal textures with a width and height as any other texture and does not cover the entire area around the light but only the area within a normal view-frustum i cannot help but wonder if it is about rendering a shadowmap for each light AND object with the camera centered on the object in each render?
I think it feels weird since this would create an exponential growth in the number of shadowmaps used in proportion to lights and objects.
I've had a hard time finding information on the subject and simply find it confusing...
So my question basicly is if this is how it works or if im missing something else?
By the way, if this question is confusing it might be because i have mostly learned this from the perspective of deferred shading but i dont think that should make much of a difference, right?
If you would use code-examples to explain something i would appreciate C# syntax by the way...

A:

No, you would not typically render a shadow map for each light AND object.  Typically there will be a fixed number of shadow maps per light (sometimes 1, sometimes more), but the number of shadow maps doesn't usually vary with the number of objects to be shadowed.
There are three kinds of lights commonly used in computer graphics: spot, point, and directional.

A spotlight only shines within a cone with some fixed width, so the shadow map frustum only needs to be big enough to cover that width.
Point lights (omnidirectional) are commonly just not shadowed at all.  But when they are shadowed, it can be done using a cubemap - 6 individual shadow maps forming a cube, each with a 90-degree-wide frustum; collectively they cover the entire sphere of directions around the light.
A directional light theoretically covers an infinite area.  In practice, if the scene is small you can simply fit a shadow map around the boundaries of the scene.  If the scene is large, such as outdoor areas in an open-world game, cascaded shadow maps or CSMs are a very good and popular solution.  CSMs take the camera's view frustum into account; they focus several shadow maps on different parts of the camera's frustum, with higher resolution closer to the camera and lower resolution farther away.

There are occasional cases where an extra shadow map might be drawn for a specific object.  For example, in a cutscene where you are doing close-ups on a character, you might like to put in an extra shadow map focused on the character's head, so you get ultra-high-quality shadows on the character.  Or in a racing game, you might put in a shadow map focused on the player's car.  But that's the exception rather than the rule, and would only be turned on for specific cases where the extra quality is desired.

