How NVIDIA Delivered Hairier Effects for Your Favorite Games

by David Murphy

Nothing against old-school gaming, but nobody likes Final Fantasy VII hair.

You know what we’re talking about — the digital look that re-creates what would happen if a character poured jars of $2 hair gel into a drum, flipped upside-down, dunked his noggin’ in, and let the mess dry in front of an industrial heater. And to think, Final Fantasy VII was at the top of its game in 1997.

The world of 3D modeling has come a long way since then. And there’s more coming, thanks to the work NVIDIA has put into its APEX physical simulation framework and PhysX real-time physics engine.

APEX is already being used to make clothes that billow and flow as a character moves or their environment changes. In BioShock Infinite, for example, the APEX clothing module allows for the real-time simulation of Elizabeth’s iconic blue dress.

The next step: applying that technology to hair. The Witcher 3: Wild Hunt, due next year, will be one of the first major titles to use NVIDIA’s new Hair/Fur APEX module, giving the hair, clothing, and fur of beasts and Witchers a flowing, lifelike look.

How does this work? Spoiler: it’s complicated. There’s a reason video games have typically lacked a strong simulation system for modeling tens of thousands of separate hair strands, in real-time. Our latest generation of GPUs – based on Kepler architecture – provides the power and efficiency to handle that kind of workload.

APEX provides the software smarts, thanks to the “Follow the Leader” technique, which treats individual strands of hair like chains of individual particles – as if a piece of hair was made out of a strand of pearls. Each ‘pearl’ has to exist within a particular radius from the one preceding it in the chain. So when the first pearl in the ‘strand’ moves, the second pearl naturally gravitates towards the closest point within the set radius of the first pearl. The third pearl follows, and then the fourth, et cetera. Easy.

It’s a trickier in a dynamic environment, especially when the “Follow the Leader” system assigns the last particle in a strand an overwhelming amount of kinetic energy. This causes the “hair” to fly around chaotically, as seen in the video below:

The solution: a correction to the velocity equation these “pearls” use when interacting with a dynamic environment. This requires a careful balance: one that preserves the realism and fluid motion of the strand without introducing a “dampening,” or loss of intensity, into the movement.

Hair Meets… Hair

Interactions between individual hair strands are handled by dividing the velocities and densities of their particles within a set space to create a single average. This average is then applied to each particle’s velocity to create a sense of friction, or the degree to which these particles’ velocities should be modified based on the interference of their surrounding environment.

Interestingly, interactions between hair and chunkier characters often don’t even need their own system or equation to be processed. If a character is rocking a shorter haircut, the “hair-hair” interaction model previously described works well to simulate the hair strands’ collisions with, say, a character’s head.

If the hair and the skin attached to it are a similar color, the “hair-hair” interaction model might not even be necessary. Otherwise, longer hair requires a collision volume to be set up – a series of eight geometric shapes (3D ellipses, in this case) that allow PhysX to detect interaction between hair and objects and respond appropriately. Clever. One could say it’s even… shear genius.