UDN
Search public documentation
ModulatedShadows
Modulated Shadows
Document Summary: Modulated Shadows are an alternative to Normal Shadows for dynamic shadows, both shadow buffers and shadow volumes. This document outlines their uses and user-controlled settings. See ShadowingReference for info on Normal Shadows. Document Changelog: Created by Daniel Wright.Overview
Modulated shadows were introduced to solve some of the performance problems with normal shadows, and to give artists more control over shadow appearances. Throughout this doc, 'normal shadows' simply means non-modulated shadows, and does not imply anything about the shadow technique. Note that modulated shadows work with both projected shadows as well as shadow volumes.Versions
ModShadowFadeoutTime functionality was introduced in QA_APPROVED_BUILD_JUNE_2007, but shadows didn't fade in as well until QA_APPROVED_BUILD_AUGUST_2007.Relevant Settings
LightShadowMode
Controls the type of shadowing used for this light source.- LightShadow_Normal - the default behavior and requires a mesh to be dynamically lit in order to receive shadows. This is a very important implication because it means lightmapped geometry cannot receive normal shadows.
- LightShadow_Modulate - enables modulated shadows from this light source, which cast on any opaque or masked object.
ModShadowColor
This controls the color of modulated shadows.ShadowFalloffExponent
Rate at which the shadows falloff based on distance for spot lights and point lights. A higher value means that the falloff will occur more quickly. A value of 1.0 equals linear falloff.ModShadowFadeoutExponent
This controls the fade-out and fade-in curves when ModShadowFadeoutTime is greater than zero.ModShadowFadeoutTime
If this is greater than zero, then the modulated shadow will fadeout based on the time that the caster was last visible. It will also fade in based on the time that the caster first became visible. This can be used to fade out shadows on characters in other rooms, whose shadows would otherwise be seen through the wall. Make sure you have realtime update on in the editor or it will not work correctly. The fade is framerate dependent so hitches may cause undesired artifacts.Why use modulated shadows
An object's dynamic shadows are drawn for each light that uses Normal Shadows. Shadows in this sense are the absence of light coming from the current light source. This is a more physically correct model, however it has some serious implications. A typical scene will have several lights in the same area, but only one of these lights casting dynamic shadows for performance reasons. In this case, shadow color is totally dependent on the lights affecting the shadowed surface. The shadow will be very dim because the shadow-casting light source only contributes a fraction of the total light on the surface, and the shadow is simply the absence of that light. It would be very difficult for an artist to tweak the shadow color and make it darker in this case, because that would require making the shadow-casting light brighter (or closer, less attenuation etc), which may ruin the lighting in the scene.Normal shadows do not cast onto static geometry once its lightmap has been built. Modulated shadows cast on the entire scene and so solve this problem.
A scene with 3 lights affecting the character, only one of them casting normal shadows. Note that the shadow is very dim.
How modulated shadows work
This is where modulated shadows come into the picture. In short, modulated shadows allow the artist to have only one shadow per dynamic object and control that shadow color without changing the lighting properties of the shadow-casting light source.Modulated shadows are much less physically correct than normal shadows, however in most cases this is offset by the performance and user control benefits. In each lighting pass the shadows have ModShadowColor applied, and then they are rendered to an attenuation buffer, instead of being used to mask out the current light. When all the lights have been rendered, the attenuation buffer is multiplied with the scene color. The result is that shadows will be darker no matter how many lights are affecting a surface, because shadows from one light source affect the light from all light sources, instead of just the shadow-casting light source.
The same scene with 3 lights affecting the character, only one of them casting modulated shadows. Note that the shadow is still strong.
Modulated shadows for point lights have a radial attenuation based on the light's radius. This is also true for spot lights except that the falloff is also affected by the inner and outer cones. For directional lights there is no distance attenuation.