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 thought that we could re-use the same shadowmap for every light. But I've seen an industry article suggesting that you can't re-use shadowmaps between lights, and have to use separate surfaces.

Do we need one shadowmap per light? Or one for the whole process?

share|improve this question
    
Perhaps. It depends which effect you want to achieve. –  Gustavo Maciel Mar 22 '12 at 23:57
add comment

1 Answer

up vote 6 down vote accepted

By "re-use the same shadowmap" I assume you mean re-use the memory (the render target). Obviously you can't re-use the data since each light has a different view of the world. :)

Anyway, yes, you can re-use the render target if you want. There are a couple of caveats. First, obviously you must design your renderer so that it only needs one shadow map at a time, which can be inconvenient or can require some changes in your pipeline. For instance, if you want to use cascaded shadow mapping for your sun light you may need a screen-space buffer to hold the shadow results, so you can accumulate multiple slices without needing to redraw your scene for each slice.

The other caveat is that you may see reduced performance, because many newer GPUs can work on multiple draw calls in parallel (even to different render targets), but this breaks if one draw call needs the result of a previous one. So if you had several shadow map render targets, the GPU might be able to parallelize (to some extent) the draw calls to draw all the shadow maps, then separately parallelize the draw calls that read the shadow maps and draw the lights. But if you have only one render target, you must serially draw shadow map A, draw light A, draw shadow map B, draw light B, etc. On high-end GPUs these operations may not saturate the GPU individually, so some cores will be left idle.

Given this, for best performance you should probably have at least two shadow map render targets and cycle through them, but it's still not obligatory to have separate render targets for each individual light. Another way is to try to provide the GPU with some other work it can use to fill the gaps---drawing particles into a separate render target, perhaps. (And as with all performance concerns, YMMV, so profile it!)

share|improve this answer
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.