This video shows my implementation of a real-time rigid body simulation on the GPU proposed by Takahiro Harada in the book GPU Gems 3. It is implemented in Unity with compute shaders in DirectX 11. The video first shows the performance of the physics engine PhysX used in Unity with 8k rigid bodies.
The GPU simulation works by representing all rigid bodies as a set of equally sized particles. Those particles are stored in a uniform grid for collision detection and reaction. Each rigid body particle corresponds to one thread in the GPU implementation to maximize parallelism.
The CPU comparison shows that Unity and PhysX on the CPU are unable to simulate more than 3k rigid bodies in real-time. Frame rates are below 3 fps for 8k rigid bodies, whereas the same amount can be simulated on the GPU at 30-40 fps. This can be optimized even further by rendering all rigid bodies using instancing* (all balls are drawn with one draw call), which results in frame rates around 140 fps. All tests were executed on an Intel i7 920 CPU and an NVIDIA GTX 750 Ti GPU.
* Instanced rendering was only useful for the GPU implementation because on the CPU 99% of the frame time were spent for the physics simulation. There would be little to no difference when using instancing for the CPU implementation with 8k rigid bodies.