Key Takeaways
- Old games used tricks like sprite flipping for reflections.
- Planar reflections and cube maps were common in early 3D games.
- Screen Space Reflection is popular, but SSR doesn’t work well for mirrors; ray tracing brings more accurate reflections.
In the real world, mirrors and shiny surfaces reflect the world around them, but video games aren’t the real world, and so developers have to figure out how to make reflections work to add depth, atmosphere, and realism to the world. The ways they done this over the years have changed, and today we’re closer to mimicking reality than ever.
How Old Games Handled Mirrors and Other Reflections
With early video game systems before the advent of mainstream 3D rendering (i.e. prior to the original Playstation’s era) 2D games used a number of ways to fake reflections. For example, if a character was running along a water stage, a developer could use “sprite flipping” where an inverted doppleganger of the character sprite would be shown on the water with a bit of filtering. Likewise, showing a character’s reflection in a mirror simply means showing a horizontally-flipped copy of the sprite.
As 3D games (or at least pseudo 3D ones) entered the market, character reflections obviously needed a different approach. One common trick was to use “portals” or duplicate rooms. The “mirror” in the game was effectively a window into another room, and a copy of your character would move in sync with you in the mirror world. You can see this in Duke Nukem 3D.
Another common technique in 3D games was the use of planar reflections. Planar reflections involve rendering the scene from the perspective of the reflective surface, such as a mirror or a body of water, and then mapping that image onto the surface.
This is a pretty effective technique, but it’s computationally expensive, or at least it was in the early days. Planar reflections are still used in games today in combination with other techniques to get the right mix of performance and reflectivity.
A great example of planar reflections is in Half-Life 2. You can tell it’s a planar reflection because the reflection doesn’t cut off near the bottom edge of the screen like more modern methods that use “screen space” do, but more on that later.
Cube maps are another clever technique to fake reflections. Here six images of the environment are placed on the six faces of a virtual cube, and then blurred. This is a good solution for shiny objects like car bodies and windshields, so lots of racing games use this method and this is the most likely method used for those reflections you see in original PlayStation racing games. Although it’s an old technique, cube maps are also still in use, along with planar reflections. It’s all about using the right method for the right object. Since the cube maps are pre-baked, they won’t reflect changes in the environment, and won’t reflect your character or other cars in a race.
Possibly the most popular modern method to create reflections in games is SSR or Screen Space Reflection. With SSR there’s no additional rendering, instead information about the scene is used to generate a dynamic reflection. This is much less expensive than rendering the entire scene again. This looks great in general, but has some major drawbacks as well.
Because SSR can only generate reflections for objects that are visible on screen, it creates different types of artifacts. SSR reflections on shiny floors or water surfaces will be cut off near the screen edges as there are no objects visible that would cast a reflection there. Also, as you look around, objects in the reflection will pop in and out of existence as things leave and enter your field of view. Look at these images, where the character looks slightly up and down. You can see the contents of the reflection change in response to what’s in the screen space.
If you’re playing a third-person game, you’ll also see weird fizzling around your character when they block something reflective like a lake. SSR uses past frame information, and so when your character moves on front of a window or water using SSR, you’ll see a fizzling around their outline, representing the lack of information to generate a reflection there.
Screen Space Reflections Don’t Work for Mirrors
It used to be common to see characters reflected in mirrors, especially in first-person games, up to the Doom 3 era, but with the rise of SSR you’re more likely to see “mirrors” that are just sort of like polished metal or dirty glass that don’t show sharp reflections.
This is because SSR doesn’t play well with mirrors and when you think about it, it makes perfect sense. Since mirrors reflect everything behind the viewer, there’s nothing in screen space to create a reflection. In a first-person game, the character isn’t visible on screen either, so there’s no way to put them in the mirror using SSR.
Ray Tracing is Bringing Mirrors Back
Which brings us to the present day and a method known as “ray tracing.” Ray tracing simulates how light propagates through space, and so it can generate accurate reflections from any angle of the entire scene. For example, Marvel’s Spider-Man games on the PlayStation 5 and later on PC have a ray tracing mode where you can clearly see the city reflected on the shiny surface of skyscrapers. Without ray tracing, you wouldn’t see those buildings at all.
Likewise, in ray-traced games, it’s possible to see yourself in the mirror from a first-person perspective, though this still isn’t common. Even Cyberpunk 2077, the poster child for ray tracing, uses planar reflections for its mirrors, which remain opaque until you activate them. However, as ray tracing becomes more mainstream, we should see a day when everything in games that should reflect your character and the environment works as it would in real life.