GPU Mass-Spring Simulator
Summary
Interactive particle and mass-springs simulator, entirely implemented on the GPU in compute shaders, using Verlet’s numerical method.
Collisions with spheres and triangle meshes are also resolved in the GPU.
This includes 3 different scenes, showing particle interaction, spring systems, and cloth by using springs.
The springs and cloth can be rendered using tessellation and B-Splines, which subdivides the primitives so the object looks smooth.
The following video shows a chain of springs rendered with and without tessellation.
By using OpenGL 4.2’s Atomic Counter, this program can simulate scenes with a dynamic number of particles, specified at runtime.
Scenes
- Particles
Dynamic creation and destruction of particles. Showing configurable bounciness and friction against external bodies.
- Springs
Mass-Spring system. Chains of springs that can be initialized to look like hair. Rendering following the Kajiya-Kay model.
For the simulation, there are 3 compute passes:- Clear spring forces.
- Compute forces per spring.
- Each particle retrieves the forces of its connected springs, computes collisions, and advects itself.
- Cloth
By connecting the particles with a grid of springs, we can compute cloth-like behavior.
It supports a simple 4-connectivity particle-spring system. And also Provot’s spring model, which can simulate stretch, shear, and bending.