Course contentsShow
← Unity Game Development
Lesson 585 of 8289. Rendering and VisualsFree lesson

Configuring Real-time Lighting and Shadow Cascades

You will configure real-time directional lights and shadow cascades to balance visual fidelity with performance in dynamic game environments.

In this lesson, you will learn how to fine-tune your directional light settings and shadow cascades to achieve a balance between sharp, high-quality visuals and efficient GPU performance.

The Balancing Act

When working with real-time lighting, the primary challenge is that rendering shadows is expensive. A single, high-resolution shadow map for a large environment would consume massive amounts of memory and processing power. To solve this, Unity uses Shadow Cascades, which split your view frustum into multiple zones.

Objects close to the camera receive a high-resolution shadow map (Cascaded Zone 0), while distant objects receive lower-resolution maps. This maintains visual fidelity where it matters most—near the player—without wasting performance on distant shadows.

Configuring Your Settings

To manage this, select your Directional Light and navigate to the Shadows section in the Inspector. Here, you define the Shadow Resolution and Cascades.

  1. Cascade Count: Increasing the number of cascades (e.g., from 2 to 4) reduces "shadow acne" and improves quality across large distances, but requires more draw calls.
  2. Split Ratio: This determines where one cascade ends and the next begins. You can visualize these partitions by going to your Scene View dropdown, selecting Shading Mode, and choosing Shadow Cascades. You will see the world segmented by different colors—adjust your ratios so that the color transitions occur at natural breakpoints in your game world.

Optimization Example

If you notice performance drops in open areas, consider adjusting your Shadow Distance in the Quality Settings. By lowering this value, you prevent the engine from calculating shadows for objects that are barely visible:

// Example of adjusting quality settings via script
QualitySettings.shadowDistance = 50.0f; 
QualitySettings.shadowCascades = 2;

By keeping your Shadow Distance tight and utilizing 2 to 4 cascades, you ensure the player sees crisp shadows where they interact with the world, while the distant environment remains performant.

Key Takeaway: Use shadow cascades to prioritize high-fidelity shadow resolution near the camera while aggressively reducing the shadow distance to maintain a stable frame rate in large, dynamic environments.