Smooth Particle Hydrodynamics

A practical guide to simulating fluids, sand, and ice on the GPU.

Smooth Particle Hydrodynamics (SPH) is a way to simulate fluids by modeling them as a collection of particles that push and pull on their neighbors. If you've seen a flocking simulation, the idea is similar: each particle follows simple local rules, and complex behavior emerges from their collective interactions.

This series builds intuition for SPH step by step. We start with the basic idea of particles influencing their neighbors, layer on forces like pressure and viscosity, move the computation to the GPU with WebGPU, and then extend the system to simulate materials beyond water.

01
Particles, Neighborhoods, and Forces

How particles estimate density and exert pressure and viscosity forces on their neighbors.

kernel functions · density · pressure · viscosity · time integration
02
Moving to the GPU

Spatial hashing, WebGPU compute shaders, and scaling to tens of thousands of particles.

spatial hash · compute shaders · WebGPU · performance
03
Beyond Water

Springs, friction, and temperature to simulate sand, ice, and elastic materials.

spring forces · granular · phase transitions · collisions · emitters
04
Playground

A full interactive sandbox combining all the pieces. Choose materials, place emitters, and paint forces.

interactive sandbox · device-adaptive