GPU-Accelerated Rigid Body Physics Simulation via WebGPU Compute
Solving impulse-based collision responses and rotational momentum equations for thousands of active rigid bodies in parallel WGSL compute workgroups.
Simulating hundreds of interacting mechanical parts or falling debris on the CPU quickly saturates main-thread processing limits. Transitioning rigid body dynamics and impulse solvers to WebGPU compute pipelines allows processing multi-thousand active object assemblies at fluid frame rates.
1. Broad-Phase Spatial Hashing on GPU Storage Buffers
Assigning moving rigid bodies to uniform 3D grid hash cells inside compute passes avoids exhaustive $O(N^2)$ collision checks, identifying potential overlapping pairs efficiently.
2. Narrow-Phase GJK / EPA Collision Detection
Executing Gilbert-Johnson-Keerthi (GJK) distance algorithms and Expanding Polytope Algorithm (EPA) contact manifold generation in parallel computes precise penetration depths and collision normal vectors.
3. Sequential Impulse Resolution & Friction
Resolving linear and angular velocity changes through sequential impulse iterations updates position matrices stored in GPU buffers directly without CPU readback bottlenecks.