Real-time fluid simulation using Smoothed Particle Hydrodynamics (SPH) — the same numerical method used in NASA astrophysics simulations and Hollywood VFX to compute realistic fluid dynamics.
Each particle carries pressure, density, and velocity. Interactions with nearby particles approximate the Navier-Stokes equations, producing viscosity, pressure gradients, and surface tension behaviour.
Click or drag on the fluid to push it. Use the sliders to change gravity, viscosity, and particle count. Try increasing particle emission from the top to simulate a waterfall.
SPH was originally developed in 1977 by Lucy and Gingold to simulate galaxy collisions in astrophysics. The same method now runs in real-time on modern GPUs to simulate water in video games.
This is a real-time fluid simulation built on Smoothed Particle Hydrodynamics (SPH), a mesh-free method that represents a liquid as thousands of moving particles rather than a fixed grid. The same technique powers astrophysics codes that model galaxy collisions and the water, lava and smoke effects seen in Hollywood films. It is fascinating because complex behaviour — splashing, sloshing and surface formation — emerges purely from simple particle-to-particle interactions.
h using a fast spatial hash grid.rho_i = sum_j m * W(r_ij, h) — density of particle i from kernel-weighted neighbour mass.
p_i = k * (rho_i - rho_0) — pressure from stiffness k and rest density rho_0.
a_i = (-grad p + mu * lap v) / rho_i + g — acceleration from pressure, viscosity mu and gravity g.
SPH was invented in 1977 by Gingold, Monaghan and Lucy to simulate fission of rotating stars — long before anyone used it for water. Particle colour here maps to pressure, so you can literally watch shockwaves of high pressure ripple through the fluid after a splash.
This simulation models a body of liquid in real time using Smoothed Particle Hydrodynamics, a mesh-free method that represents the fluid as up to 2,000 moving particles instead of a fixed grid. Each particle computes its local density and pressure from neighbours found within a smoothing radius, then responds to pressure, viscosity and gravity forces using the Müller (2003) SPH kernels. Splashing, sloshing and free-surface motion all emerge from these simple particle-to-particle interactions.
Liquid behaviour inside a wireframe tank, computed with SPH. A spatial-hash grid finds each particle's neighbours within radius h, the poly6 kernel sums density, pressure follows p = k(rho - rho0), and spiky and viscosity Laplacian kernels supply pressure and viscous forces before semi-implicit Euler integration.
Six sliders set particle count (200-2000), gravity (0-20), pressure stiffness, viscosity, kernel radius h (0.5-3) and wall damping. Drag to rotate the camera and scroll to zoom. Press Restart to rebuild the block of fluid, or Wave to fire an upward splash impulse into a random third of the particles.
SPH was invented in 1977 by Gingold, Monaghan and Lucy to model the fission of rotating stars in astrophysics, long before it was ever applied to water. Here each particle's colour maps to its pressure, so you can watch high-pressure shockwaves ripple through the liquid after a splash.
SPH is a mesh-free numerical method that represents a fluid as a set of discrete particles, each carrying mass, velocity, density and pressure. Field quantities are estimated by summing smoothing-kernel-weighted contributions from neighbouring particles within a radius h. Because there is no fixed grid, it handles splashing free surfaces and large deformations naturally.
Each step it builds a spatial-hash grid, then for every particle it sums neighbour contributions to get density with the poly6 kernel and derives pressure from p = k(rho - rho0). Pressure forces use the spiky kernel gradient and viscosity uses the viscosity-kernel Laplacian, after which gravity is added and positions are advanced by semi-implicit Euler integration.
Particles sets how many points make up the liquid, Gravity is the downward acceleration, and Pressure is the stiffness k that resists compression and keeps the fluid roughly incompressible. Viscosity is internal friction that makes the fluid thicker, Kernel radius h is the neighbour interaction distance, and Damping is the fraction of speed retained after each wall bounce.
It captures the qualitative behaviour of a real liquid, including pressure gradients, viscous drag and wall collisions, but it is a simplified real-time model. The particle count is limited for smooth frame rates, the kernels are the standard Müller 2003 approximations, and parameters use simulation units rather than calibrated physical values, so results are illustrative rather than quantitatively exact.
Colour encodes each particle's pressure, mapped from blue at low pressure through cyan and green to red at the highest pressure in the current frame. This makes compression visible: after pressing Wave you can see bands of high pressure travel through the fluid as a shockwave before the liquid settles back under gravity.