Shadowmask is a version of the Shadowmask lighting mode shared by all Mixed Lights in a Scene. To set Mixed lighting to Shadowmask:
A shadow mask is a Texture that shares the same UV layout and resolution with its corresponding lightmap. It stores occlusion information for up to 4 lights per texel, because Textures are limited to up to 4 channels on current GPUs.
Unity precomputes shadows cast from static GameObjects onto other static GameObjects, and stores them in a separate Shadowmask Texture for up to 4 overlapping lights. If more than 4 lights overlap, any additional lights fall back to Baked Lighting. Which of the lights fall back to Baked Lighting is determined by the baking system and stays consistent across bakes, unless one of the lights overlapping is modified. Light Probes also receive the same information for up to 4 lights.
Light overlapping is computed independently of shadow receiving objects. So, an object can get the influence of 10 different mixed lights all from the same Shadowmask/Probe channel, as long as those light bounding volumes don’t overlap at any point in space. If some lights overlap then more channels are used. And, if a light does overlap while all 4 channels have already been assigned, that light will fallback to fully baked.
In Shadowmask mode:
Static GameObjects receive shadows from other static GameObjects via the shadow mask, regardless of the Shadow Distance (menu: Edit > Project Settings, then select the Quality category, and navigate to the Shadows section). They also receive shadows from dynamic GameObjects, but only those within the Shadow Distance.
Dynamic GameObjects receive shadows from other dynamic GameObjects within the Shadow Distance via shadow maps. They also receive shadows from static GameObjects, via Light Probes. The shadow fidelity depends on the density of Light Probes in the Scene, and the Light Probes mode selected on the Mesh Renderer.
Unity automatically composites overlapping shadows from static and dynamic GameObjects, because shadow masks (which hold static GameObject lighting and shadow information) and shadow maps (which hold dynamic GameObject lighting and shadow information) only encode occlusion information.
A good example of when Shadowmask mode might be useful is if you are building an almost fully static Scene, using specular Materials, soft baked shadows and a dynamic shadow caster, not too close to the camera. Another good example is an open-world Scene with baked shadows up to the horizon, but without dynamic lighting such as a day/night cycle.
The following table shows how static and dynamic GameObjects cast and receive shadows when using Shadowmask mode:
A dynamic GameObject that is receiving a shadow from another static or dynamic GameObject
A static GameObject that is receiving a shadow from another static or dynamic GameObject
|Within Shadow Distance||Beyond Shadow Distance||Within Shadow Distance||Beyond Shadow Distance|
A dynamic GameObject that is casting a shadow
|Shadow map||-||Shadow map||-|
A static GameObject that is casting a shadow
|Light Probes||Light Probes||Shadowmask||Shadowmask|
The performance requirements of Shadowmask mode make it a good option for building to low and mid-range PCs, and mobile devices. These are the most significant advantages and disadvantages of using Shadowmask mode:
It offers the same visual effect as Realtime Lighting.
It provides real-time shadows from dynamic GameObjects onto static GameObjects.
One Texture operation in the Shader handles all lighting and shadows between static GameObjects.
It automatically composites overlapping shadows from static and dynamic GameObjects.
It has mid-to-low performance requirements, because it does not render static GameObjects into shadow maps.
It provides indirect lighting.
It only provides low-resolution shadows from static GameObjects onto dynamic GameObjects, via Light Probes.
It only allows up to 4 overlapping light volumes (see documentation under the ‘Technical details’ section of Mixed Lighting for more information).
It has increased memory requirements for the light map Texture set.
It has increased memory requirements for the shadow mask Texture.
2017–09–18 Page amended
Light Modes added in 5.6
Added advice on light overlap computation in Unity 2017.1