Version: 2019.2
Shadowmask mode
Distance Shadowmask

Shadowmask

Shadowmask is a version of the Shadowmask lighting mode shared by all Mixed Lights in a Scene. To set Mixed lighting to Shadowmask:

  • Open the Lighting window (menu: Window > RenderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
    See in Glossary
    > Lighting Settings), click the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
    See in Glossary
    tab, navigate to Mixed LightingA Light Mode for creating indirect lighting, shadowmasks and subtractive lighting. Indirect lighting gets baked into lightmaps and light probes. Shadowmasks and light probes occlusion get generated for baked shadows. More info
    See in Glossary
    and set the Lighting Mode to Shadowmask.
  • Next, open the Quality settings (menu: Edit > Project SettingsA broad collection of settings which allow you to configure how Physics, Audio, Networking, Graphics, Input and many other areas of your Project behave. More info
    See in Glossary
    , then select the Quality category), navigate to Shadowmask Mode and set it to Shadowmask.

See documentation on Mixed lighting to learn more about this lighting mode, and see documentation on Light modesA Light property that defines the use of the Light. Can be set to Realtime, Baked and Mixed. More info
See in Glossary
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 lightmapA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary
. 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 GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
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 volumesA closed shape representing the edges and faces of a collider or trigger. More info
See in Glossary
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 ShadowsA UI component that adds a simple outline effect to graphic components such as Text or Image. It must be on the same GameObject as the graphic component. More info
    See in Glossary
    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 ProbesLight probes store information about how light passes through space in your scene. A collection of light probes arranged within a given space can improve lighting on moving objects and static LOD scenery within that space. More info
    See in Glossary
    mode selected on the MeshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
    See in Glossary
    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 cameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary
. 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 receiverA dynamic GameObject that is receiving a shadow from another static or dynamic GameObject More info
See in Glossary

A dynamic GameObject that is receiving a shadow from another static or dynamic GameObject
Static receiverA static GameObject that is receiving a shadow from another static or dynamic GameObject More info
See in Glossary

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 ShaderA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
    See in Glossary
    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 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

Did you find this page useful? Please give it a rating:

Shadowmask mode
Distance Shadowmask