A stunning real-time 2D fluid simulator powered by Smoothed Particle Hydrodynamics. Watch 5,000 particles dance under gravity, pressure, and viscosity — rendered as a beautiful continuous fluid with Phong lighting.
Every drop is simulated. Every wave is emergent. No shortcuts, no pre-baked animations.
Smoothed Particle Hydrodynamics with spatial hashing for O(1) neighbor lookups. Density, pressure, and viscosity forces create authentic fluid behavior.
Gaussian splat pass creates a smooth density field, then a fluid pass extracts the surface with gradient-based normals and Phong lighting with specular highlights.
Sub-frame physics stepping ensures rock-solid stability even with thousands of particles colliding and splashing in the container.
Push water with your mouse, spawn particles on the fly, and reset instantly. The simulation responds to your every move in real time.
Hardware-accelerated rendering with off-screen framebuffers, additive blending, and shader-based surface extraction for buttery smooth visuals.
No bloated frameworks. Pure C++17 and OpenGL — boots in under a second and runs at 60 FPS on modest hardware. GLFW is the only dependency.
Screenshots showcasing the fluid simulation in action.
Two elegant systems working in harmony to bring water to life.
Particles are bucketed into a grid where each cell matches the smoothing radius. Neighbor lookups become O(1) instead of O(n²), making 5,000 particles feel effortless.
A Poly6 kernel estimates density from nearby particles. Pressure derives from density using a stiffness coefficient — only positive pressures are kept to prevent vacuum collapse.
Spiky gradient kernels create pressure forces that push particles apart. Viscosity forces via Laplacian kernels smooth velocity differences for that satisfying, realistic flow.
Gaussian splats create a density field, then the fluid pass extracts the surface, computes normals from gradients, and applies Phong lighting with depth-based color shifts.
Push water away from your cursor
Hold to spawn particles at cursor
Reset the entire simulation
Quit the application
Download the simulation and experience real-time fluid physics on your own machine. Free, open-source, and runs on any OpenGL 3.3 capable GPU.