Lighting the Way

Did you know that dynamic lighting can make or break the immersion in a game? In fact, real-time lighting effects are one of the most resource-intensive processes in modern game engines, accounting for up to 30% of the total rendering load in some AAA titles.

A young man sitting at a table, illuminated in blue and red light, holding a video game controller. He appears to be focused on the game. The image captures the immersive nature of gaming and the use of dynamic lighting effects.
Photography by Mayan Sachan on Unsplash
Published: Tuesday, 03 December 2024 02:06 (EST)
By Wei-Li Cheng

Back in the early days of gaming, lighting was a simple affair. Developers relied on static lighting baked into textures, meaning the light and shadows you saw in a game were pre-rendered and unchanging. This worked fine for the pixelated worlds of the 80s and 90s, but as graphics evolved, so did our expectations. Players wanted more realism, more immersion, and more dynamic environments. Enter dynamic lighting.

Dynamic lighting, unlike its static counterpart, reacts to changes in the game world. Whether it’s the flicker of a torch in a dark dungeon or the shifting shadows of clouds passing overhead, dynamic lighting adds a layer of realism that static lighting simply can’t match. But how do game engines pull off these effects without turning your gaming rig into a toaster? Let’s break it down.

1. Real-Time Shadows

One of the most noticeable aspects of dynamic lighting is real-time shadows. In older games, shadows were often just dark blobs under characters or objects. But modern game engines use complex algorithms to calculate how light interacts with objects in real-time, creating shadows that move and change based on the light source. This is especially important in open-world games where the sun’s position changes throughout the day, casting different shadows as time progresses.

Real-time shadows are typically handled using a technique called shadow mapping. The engine renders the scene from the perspective of the light source, creating a depth map that determines which areas are in shadow. This map is then used to apply shadows to the final image. While effective, shadow mapping can be resource-heavy, especially in scenes with multiple light sources.

2. Global Illumination

Global illumination (GI) is the holy grail of realistic lighting. It simulates how light bounces off surfaces, illuminating areas that aren’t directly hit by a light source. Think of how sunlight streams through a window and reflects off the floor, subtly lighting up the rest of the room. That’s global illumination in action.

Game engines typically use a combination of pre-calculated lightmaps and real-time techniques to achieve GI. While fully real-time GI is still a challenge due to its computational demands, engines like Unreal and Unity have made significant strides in recent years, offering hybrid solutions that balance performance and realism.

3. Volumetric Lighting

Ever noticed those cool god rays streaming through the trees in your favorite RPG? That’s volumetric lighting at work. Volumetric lighting simulates how light interacts with particles in the air, like dust, fog, or smoke, creating beams of light that add depth and atmosphere to a scene.

To achieve this effect, game engines render the scene from the perspective of the light source and calculate how much light is scattered as it passes through the air. This data is then used to create the volumetric lighting effect. While it’s a relatively subtle effect, it can make a big difference in creating a sense of scale and immersion.

4. Light Probes

Light probes are a clever way game engines simulate dynamic lighting in large, open environments without taxing your GPU. Essentially, light probes are points in the game world that capture lighting information from their surroundings. This data is then used to light objects and characters in the scene, even if they’re far away from the main light source.

By using light probes, game engines can create the illusion of dynamic lighting without having to calculate the lighting for every single object in real-time. This technique is especially useful in open-world games where the player can move freely between different environments.

5. Screen-Space Reflections (SSR)

Screen-space reflections are a technique used to simulate reflections in real-time. Whether it’s the reflection of a character in a puddle or the gleam of a neon sign on a wet street, SSR adds a layer of realism to dynamic lighting.

SSR works by using the information already rendered on the screen to calculate reflections. While this technique is less accurate than ray tracing, it’s much more performance-friendly and can still produce impressive results. Many modern games use a combination of SSR and ray tracing to balance performance and visual fidelity.

As game engines continue to evolve, so too will the techniques used to handle dynamic lighting. Just as static lighting gave way to dynamic lighting, we’re likely to see even more advanced methods in the future, perhaps even fully real-time global illumination in every game. Until then, the techniques we’ve discussed will continue to light the way for immersive, realistic gaming experiences.

After all, just like in the early days of gaming, it’s the lighting that often sets the mood and draws us into these virtual worlds.

Gaming