Distance Shadowmask mode
Subtractive mode
Other Versions

Shadowmask mode

Shadowmask mode is a lighting mode shared by all Mixed Lights in a Scene. To set Mixed lighting to Shadowmask, open the Lighting window (menu: Window > Lighting > Settings), click the Scene tab, navigate to Mixed Lighting and set the Lighting Mode to Shadowmask. See documentation on Mixed lighting to learn more about this lighting mode, and see documentation on Light modes to learn more about the other modes available.

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. Light Probes also receive the same information for up to 4 lights.

In Shadowmask mode:

  • Static GameObjects receive shadows from other static GameObjects via the shadow mask, regardless of the Shadow Distance (menu: Edit > Project Settings > Quality > Shadows). 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.

Shadows

The following table shows how static and dynamic GameObjects cast and receive shadows when using Shadowmask mode:

Dynamic receiver
A dynamic GameObject that is receiving a shadow from another static or dynamic GameObject
Static receiver
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
Dynamic caster
A dynamic GameObject that is casting a shadow
Shadow map - Shadow map -
Static caster
A static GameObject that is casting a shadow
Light Probes Light Probes Shadowmask Shadowmask

Advantages and disadvantages of Shadowmask mode

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:

Advantages

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

Disadvantages

  • 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 on Technical Details for more information).

  • It has increased memory requirements for the light map Texture set.

  • It has increased memory requirements for the shadow mask Texture.


Distance Shadowmask mode
Subtractive mode