GameWorks Makes Physically Simulated Worlds Possible

by Rev Lebaredian

We’re releasing two new technologies at this week’s Game Developers Conference that bring us closer to the dream of fully physically simulated worlds.

A demo of our physics engine back in 2002.

GPU Rigid Bodies and NVIDIA Flow are available immediately through our new GameWorks 3.1 SDK, which can be downloaded through our developer zone.

The product of several engineer-years of work, they enable the worlds that are simulated inside of games and applications to get a step closer to behaving like the real one.

Introducing GPU Rigid Bodies

Rigid body dynamics simulation hit mainstream gaming when Half-Life 2 teased us with videos in 2002. There have been many evolutionary advancements in rigid body dynamics since then. But ultimately, the scale of these simulations has been limited by the computing power available on CPUs.  

Our large scale destruction demo from GDC 2013 still used a simplified, special purpose algorithm

Simulating something as common in video games as the destruction of a building requires computing the interaction between tens of thousands of rigid bodies representing chunks and debris. The compute limitations of CPUs force game developers either to avoid this sort of effect — make the destruction a canned animation sequence — or limit the scale of destruction by only simulating a small number of chunks that disappear soon after the effect begins.

Our solution is to move the rigid body workload for large simulations over to the GPU. We’ve been hacking away at this problem for a long time because, as it turns out, rigid body solvers are difficult to map to massively parallel machines, such as a GPU.

We’ve finally cracked it. You can now run on GPUs the same solver that runs today on CPUs  in hundreds of games, without any loss of fidelity. Furthermore, since there are no behavioral differences between the CPU and GPU versions of the algorithm, we can switch the workloads between them with a flip of the switch.

Our new GPU rigid body demo supports the full software PhysX feature set, such as the actuated joints used for the legs of the walking creatures.
Our new GPU rigid body demo supports the full software PhysX feature set, such as the actuated joints used for the legs of the walking creatures.

Going with the (NVIDIA) Flow

Fluid dynamics is another notoriously difficult problem to solve, but we’ve been working at it for a long time. NVIDIA Flow is our latest computational fluid dynamics  solution, allowing us to simulate fluid behavior such as combustible fluids, fire and smoke in real time.

Video: Our 2007 fluid dynamics demo was still enclosed to a box because of the static simulation grid.

We’ve integrated NVIDIA Turbulence in recent years into many games, advancing the state of the art in real-time fluids in gaming. Turbulence — like many other CFD solvers — solves the motion of the fluids being simulated inside a bounded area. This box is subdivided into smaller cells (voxels), each containing information about the density, velocity and temperature of the fluid within that area.

The simulation grid of the fireball gets allocated as it flies through the world, freeing the effect from the confines of a box.

An unfortunate consequence of this type of solution is that when the fluid expands outside the confines of the box, you have to choose between several somewhat undesirable options. You can pretend there’s no fluid outside the box, making it look like the fluid is in a glass box of sorts. You can expand the box, but then you either have to lose resolution of the fluid by maintaining the same number of cells. Or you can increase the number of cells, and consume more memory and computational resources.

Our new solution — NVIDIA Flow — sidesteps this problem by only allocating cells near areas where the fluid exists. As the fluid expands, it allocates new cells where it’s expanding, and deallocates them where the fluid is dissipating. It keeps the size of the cells constant. So it maintains the resolution and fidelity regardless of the shape and positioning of the fluid.  

The result: artists no longer have to spend their precious time tuning resolution parameters and placing bounding boxes — making trade-offs between artifacts and resource availability. NVIDIA Flow will magically do the right thing. So the artist can focus on what matters — making beautiful fluids.