0
\$\begingroup\$

The basic implementations of shadow mapping that I have seen create a depth texture for each light source affecting the scene. I'm just curious as to why this might be done rather than using and reusing a single texture for all of the lights in the scene so as to save on memory.

To clarify, is there any benefit in the following:

for light in lights
    render scene depth to light.shadowTexture // One texture object per light
end

for light in lights
    render scene with light (blended)
end

as opposed to:

new Texture shadowMap // One texture object, written to by all lights

for light in lights
    render scene depth to shadowMap
    render scene with light (blended)
end
\$\endgroup\$
2
\$\begingroup\$

In addition to bogglez answer (you don't need to re-render shadow maps which haven't changed between frames), there is also the possibility to render several lights at once if each light has its own shadow map. This is more of an issue with a forward (i.e. non-deferred) renderer where you want to avoid churning through all the geometry in your scene for each light.

You can also group lights together according to which geometry objects they intersect and re-use a small pool of shadow maps if you can't afford to have a shadow map per light.

\$\endgroup\$
2
\$\begingroup\$

In the first solution you can keep the shadow map if nothing changed, in the second solution you always need to re-render the shadow map. That makes the first solution better for scenes which are somwhat static.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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