Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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...

share|improve this question
1  
tinyurl.com/p6grfng Look at this. You render shadowmap for each light that casts shadow (That means draw scene from the view point of the light). And you only need to know where it casts shadow inside frustrum you are looking at. You draw scene from the view point of light and store depths of everything you render - shadow map is actually a depth map from lights perspective. Then you use these depth maps from all lights for comparison with cameras depth map to know which pixels are shadowed (if your camera sees pixel that light doesnt see, then there is a shadow). –  Kikaimaru Jun 7 '13 at 19:09
    
I have been through that tutorial and a couple others but did for some reason not find the answer to my question. I already understood the depthmap concept and just wondered how to cover the entire surroundings of the point-light. Anyways, i got my answer below but thanks for answering! And by the way... As far as i know i should not compare the 2 depthmaps to eachother but rather the light's depthmap to the distance from the pixel to the light in order to get an accurate result. –  DOOMDUDEMX Jun 7 '13 at 22:04
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Very good answer! The cubemap was what i was looking for. Sorry if i left som info out, i think i could be more specific. However, those 6 maps should then all be rendered in 1:1 aspect ratio then. I guess what confused me was that the shadomaps i had seen was in a wider aspect ratio. From here i guess it is just to check the angle from each pixel to the lightsource in order to know which of the 6 shadowmaps to use and compare the depth with the distance from the pixel to light right? –  DOOMDUDEMX Jun 7 '13 at 22:00
    
@DOOMDUDEMX Yes. DX11-level GPUs support depth cubemaps directly, so you wouldn't even have to choose the cube face yourself; you could just feed in the vector from the light source to the pixel and it will figure out which cube face to use. On older GPUs you might have to do the math yourself. –  Nathan Reed Jun 7 '13 at 22:19
    
Oh, that sounds nice! Ill have to look into that! Even though the math isn't too advanced i'll assume that the built in functions come with better performance! Thanks again for some high quality help! –  DOOMDUDEMX Jun 7 '13 at 23:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.