Unity Pro makes it possible to use real-time shadows on any light. Objects can cast shadows onto each other and onto parts of themselves (“self shadowing”). Directional, Spot and Point lights support shadows.
Using shadows can be as simple as choosing Hard Shadows or Soft Shadows on a Light. However, if you want optimal shadow quality and performance, there are some additional things to consider.
The Shadow Troubleshooting page contains solutions to common shadowing problems.
Curiously enough, the best shadows are non-realtime ones! Whenever your game level geometry and lighting is static, just precompute lightmaps in Unity. Computing shadows offline will always result in better quality and performance than displaying them in real time. Now onto the realtime ones…
Unity uses so called shadow maps to display shadows. Shadow mapping is a texture based approach, it’s easiest to think of it as “shadow textures” projecting out from lights onto the scene. Thus much like regular texturing, quality of shadow mapping mostly depends on two factors:
Different Light types use different algorithms to calculate shadows.
Details on how shadow map sizes are computed are in Shadow Size Details page.
Realtime shadows are quite performance hungry, so use them sparingly. For each light to render its shadows, first any potential shadow casters must be rendered into the shadow map, then all shadow receivers are rendered with the shadow map. This makes shadow casting lights even more expensive than Pixel lights, but hey, computers are getting faster as well!
Soft shadows are more expensive to render than hard shadows. The cost is entirely on the graphics card though (it’s only longer shaders), so hard vs. soft shadows don’t make any impact on the CPU or memory.
Quality Settings contains a setting called - this is how far from the camera shadows are drawn. Often it makes no sense to calculate and display shadows that are 500 meters away from the camera, so use as low shadow distance as possible for your game. This will help performance (and will improve quality of directional light shadows, see above).
Built-in shadows require a fragment program (pixel shader 2.0) capable graphics card. The following cards are supported: