Nowadays, all 3D games feature dynamic shadows. They are a must have to correctly estimating distances. So how does it work? Let’s have a look at a simple case, the shadows of Mario Kart 8 Deluxe on Nintendo Switch.

Mario Kart uses pre-calculated shadows for scenes and static objects. When a level is ready, devs just have to run a shadow calculation that will be reused in the game. This ensures realistic shadows at low cost.

Ecran d'intro de la carte Mario Kart Stadium de Mario Kart 8 Deluxe.

For characters, objects and some dynamic level elements, the game uses shadows calculated in real time. These are easily distinguished from pre-calculated shadows by their sharp edges.

Difference between dynamic planes (1,2) and static ones (3,4), Azur Airport.

Having dynamic soft shadows adds a significant performance cost, which is why the majority of Switch games do without them (even Zelda: TOTK).

To achieve dynamic shadows, games often rely on Shadow Maps (SM). By placing a camera where the light is, they create a texture (Depth Map) containing for each pixel the distance between the light and the nearest object. This distance enables them to detect, during the main render, whether a pixel seen on screen is behind what the light sees.

Diagram of how a shadow map works. Real-Time Shadows. Schéma du fonctionnement des shadows maps. Ombres Temps-Réels.

Like 90% of recent games, Mario Kart uses an evolution of the SM called Shadow Cascades. The idea is to render several SM of different sizes, depending on the distance from the player. The result is precise close shadows thanks to a texture covering a restricted area.

Diagram of how shadow cascades work. Real-Time Shadows. Schéma du fonctionnement des shadows cascades. Ombres Temps-Réel.

In Mario Kart, dynamic shadows are generated using only a directional light (sunlight). It illuminates the entire level uniformly.

The drawback is that there are no shadows indoors, even when there are lights. Managing shadows for several sources at once is too costly for the Nintendo Switch.

In some cases, the game acts as if we were outdoors to highlight an element. Thanks to this and road deformation, Bowser seems to emit light in Bowser’s Castle.

For the shadows in the night levels, Mario Kart 8 has daylight-like lighting. As the shadows are most visible when the ground is lit up, it looks as if they’re coming from street lamps. The shadow direction is not right, but the result is convincing enough.

Mario Kart’s dynamic shadows are based on tricks and have obvious flaws. But players don’t notice them, and it doesn’t distract from their enjoyment of the game.

Next-gen AAA games are (almost) all based on the same shadow management method. But they supplement it with other, more complex methods to add details and realism.

If you’re interested in the subject of dynamic shadows, I’ve posted a more complete and deep article. In it, you’ll find the different methods used in the industry with examples and the advantages/disadvantages of each. ⏬⏬