4.2.6 Shadows in Unity

Shadows help add perspective and realism to your scenes. Without them it can sometimes be difficult to tell the depth of objects, especially if they are similar to the surrounding objects.

Shadow algorithms can be very complex, especially when rendering high resolution accurate shadows. Ensure you select an appropriate level of complexity and resolution for the shadows in your game.
Unity supports transform feedback for calculating real-time shadows.


The Ice Cave demo implements custom shadows. Shadows based on local cubemaps are combined with shadows rendered at runtime.
Unity has a number of options for shadows under Edit > Project Settings > Quality that can impact the performance of your game:
Hard/Hard and Soft Shadows
Soft shadows look more realistic but take longer to calculate.
Shadow Distance
The Shadow Distance option defines the distance from the camera that shadows appear in. Increasing the shadow distance increases the number of shadows visible, and this increases the computational load. Increasing the shadow distance also increases the number of texels available for the shadows in the shadow map, passively increasing the resolution of your shadows.
You can use hard shadows with a small shadow distance and a high resolution. This produces reasonable quality shadows within a good distance of the camera that are not too complex.
Light mapped objects do not produce realtime shadows, the more static shadows you can bake into the scene fewer less real-time calculations your GPU must do.
The following figure shows an alien character with a shadow:
Figure 4-21 Alien with shadow

Use real-time shadows sparingly

Real-time shadows can dramatically enhance the realism of a scene but they are computationally expensive.

On mobile devices, try to limit the number of lights that include real-time only shadows and try to use lightmapping instead.
Consider the mesh renderer component of the objects in your scene. If you do not intend to use them for casting or receiving shadows disable the Cast Shadows and Receive Shadows options accordingly. This reduces the computation cost of rendering shadows.
You can find more settings for shadows in the Quality Settings section such as:
  • Shadow Resolution enables you to select the balance between quality and processing time.
  • Shadow Distance enables you to limit shadow generation to objects close to the camera.
  • Shadow Cascades enables you to select the balance between quality and processing time. You can set this to zero, two or four. Cascaded Shadow Maps are used for directional lights to achieve very good shadow quality, especially for long viewing distances. A higher number of cascades produces better quality, but increases processing overhead.
Non-ConfidentialPDF file icon PDF versionARM 100140_0201_00_en
Copyright © 2014, 2015 ARM. All rights reserved.