Dynamic Day-Night Cycles and Baked Shadows in Games
Integrating dynamic day-and-night cycles into open-world games presents a technical challenge when static baked lighting and shadow maps are involved. Because standard baked shadows contain fixed directional and intensity data, altering the sun's position can cause visual artifacts, conflicting shadows, or static light pools at midnight. Game developers overcome this limitation by using hybrid rendering strategies, such as shadowmask lightmapping, lightmap runtime modulation, time-of-day lightmap blending, and separating indirect global illumination from dynamic directional shadows.
1. Shadowmask and Occlusion Baking
Instead of baking full direct illumination and hard directional shadows, engines bake a "shadowmask." A shadowmask is a low-overhead texture that stores only occlusion data (which static objects occlude direct light) rather than hardcoded light color and direction. At runtime, the dynamic directional sun or moon uses this mask to determine where static objects cast shadows, seamlessly blending real-time shadows from dynamic characters with baked static geometry without casting conflicting light.
2. Separating Indirect GI from Direct Shadows
A widely adopted technique is to bake only indirect light (diffuse bounces and ambient occlusion) into lightmaps or volumetric light probes, leaving direct shadows completely dynamic. Because ambient occlusion and bounce light from skylight are less sensitive to rapid angle shifts than sharp directional shadows, they can be tinted or scaled at runtime without breaking visual immersion. The sun and moon then cast dynamic Cascaded Shadow Maps (CSM) across the environment.
3. Lightmap Tinting and Runtime Modulation
For performance-constrained platforms, developers modify baked lightmap data directly in the pixel shader based on the current time-of-day parameters. By multiplying the baked luminance by real-time ambient color gradients, skylight intensities, and sun angles, baked shadows can darken realistically during night or shift to warm tones during golden hour. While this does not alter the physical direction of baked shadows, it prevents them from appearing unnaturally bright at night.
4. Multi-State Lightmap Blending
For games requiring high visual fidelity with baked global illumination across distinct times of day, studios bake multiple sets of lightmaps—typically representing noon, sunset, and midnight. Shaders then interpolate between these textures based on the game's internal clock. While memory-intensive, texture compression and sparse virtual texturing allow engines to smoothly crossfade baked lighting and shadow intensities across varying sun elevations.
5. Distance-Based Dynamic Shadow Cascades
In open-world architectures, dynamic Cascaded Shadow Maps are prioritized for the near-to-mid field, completely overriding baked direct lighting around the player. At far distances, where real-time shadow rendering becomes expensive, the engine smoothly transitions to screen-space ambient occlusion (SSAO), directional distance field shadows, or neutralized ambient maps. This prevents jarring transitions where baked directional data would otherwise conflict with dynamic geometry.