The virtual world of Grand Theft Auto V has it all. Gritty urban neighborhoods packed with action and intrigue. Sprawling forests and canyons teeming with wildlife. Even, um, immersive undersea environments ready for you to explore. It vividly demonstrates that no one can touch GTA V developer Rockstar Games when it comes to building digital realms.
It’s a great case study for how a technique we call NVIDIA Percentage-Closer Soft Shadows (PCSS) can add nuance and realism to virtual worlds.
PCSS, part of our NVIDIA GameWorks library of developer tools, allows game developers to easily put realistic shadows in their games. Shadows are key to creating more realistic worlds because the human brain can perceive subtle differences in images – both consciously and unconsciously.
Here’s how it works:
In nature, the closer a shadow is to the object casting the shadow, the more detailed it is. Conversely, the further the shadow is from the object casting the shadow, the more diffuse, or softer, it is.
NVIDIA PCSS mimics this. Shadows progressively soften as the distance from the objects casting them increases. PCSS also reduces the prominence of shadow aliasing – the jagged lines on the edges of shadows. Additionally, PCSS uses a shadow buffer to handle overlapping character shadows to eliminate “double-darkened” portions. And because PCSS is powered by DirectX 11, it works on DX11-capable GPUs from any vendor.
The picture below, from GTA V, shows the benefits. The shadow for the motorcycle on the left is more detailed because it’s close to the motorcycle. Only a small amount of diffusing occurs. In contrast, the palm tree’s shadow becomes more diffuse as the distance from the palm tree to its shadow increases.
Another example is below. The tree trunk’s shadow is sharp at the base but softer as you travel along the shadow to the canopy of the tree.
Now compare it to a real shadow photographed on our campus (below). The shadow is sharp at the base of the tree trunk and becomes softer as you travel up the shadow to the tree’s canopy.
PCSS only gets better as shadows become more complex.
The shadow on the sidewalk in this canal scene below is an effect you’ve surely seen before. Leaves and limbs overlap, blocking out most of the light. Light pops though gaps in the canopy. A rendering that didn’t do a good job of factoring in distance would result in unrealistic shadows.
Let’s look at another complex scene. The GTA V screenshot below could almost be a photo. Notice how the PCSS shadow of the Ferris wheel softens with distance. And notice how the shadow of the rollercoaster track softens as the track ascends.
The result is more than just great screen shots. It’s a visual world free of aliasing and stenciled shadows that remind gamers that “this is just a video game.” Soft shadows provide valuable cues about spatial relationships that help users understand, intuitively, that they’re inside a carefully constructed world.