Course contentsShow
← Unity Game Development
Lesson 698 of 82810. VFX and Post-ProcessingFree lesson

Configuring Real-Time Lighting for Performance

You will learn to balance light intensity and shadow distance settings to maintain high framerates in complex 3D environments.

In this lesson, you will learn how to strategically calibrate light intensity and shadow distance to maintain high-performance standards in complex, visually dense 3D environments.

Balancing Intensity and Culling

As scenes grow in complexity, the GPU cost of real-time lighting—specifically shadow map generation—becomes a significant performance bottleneck. The goal is to ensure high-quality lighting remains visible only where the player is focused, while shedding expensive computations for distant or unimportant areas.

Shadow distance is the primary lever for performance. By default, Unity calculates shadows for all objects within the camera’s view frustum. In a complex scene, you should define a Shadow Distance in your Universal Render Pipeline Asset that matches the scale of your local gameplay zone. Objects beyond this threshold will have their shadows culled, saving vast amounts of draw calls and depth-pass calculations.

Managing Light Complexity

When dealing with multiple real-time light sources, you must balance their Intensity and Range against their Culling Mask settings. To optimize, ensure that high-intensity lights affecting large areas are limited to essential layers:

// Example: Dynamically adjusting shadow quality based on platform constraints
void AdjustShadowQuality(float distance) {
    // Reduce shadow distance for performance-heavy scenes
    QualitySettings.shadowDistance = distance;
    
    // Disable shadow casting for non-critical dynamic lights
    Light[] lights = FindObjectsOfType<Light>();
    foreach (Light light in lights) {
        if (light.intensity < 1.0f) {
            light.shadows = LightShadows.None;
        }
    }
}

By capping the intensity of secondary lights and strictly limiting the shadow distance, you prevent the engine from performing redundant calculations on distant geometry that the player likely won't notice. Focus your real-time "shadow budget" on the immediate vicinity of the player, while allowing ambient lights to remain shadow-less. This tiered approach ensures that your scene remains visually rich while preserving the framerate required for complex, particle-heavy environments.

Key Takeaway: Effective real-time lighting performance relies on aggressive shadow distance culling and minimizing the number of shadow-casting lights rendered outside the immediate area of player interaction.