three-fluid-simulation

Installation
SKILL.md

Real-Time Fluid Simulation in a Web 3D Scene

What this builds

A GPU-accelerated 2D fluid simulation based on Jos Stam's "Stable Fluids" method, running entirely in fragment shaders via render-to-texture. The simulation solves the incompressible Navier-Stokes equations in real time: advection moves the fluid, pressure projection enforces incompressibility (mass conservation), and vorticity confinement restores small-scale curls lost to numerical diffusion. Interactive dye and force injection from mouse/touch creates the classic "ink in water" effect.

  • Full Navier-Stokes solver: advection, diffusion, pressure solve (Jacobi iteration), divergence correction
  • Vorticity confinement to preserve swirling details the solver would otherwise smooth away
  • Mouse/touch-driven force and dye injection (splat)
  • Multi-resolution simulation: low-res velocity field, high-res dye rendering
  • Bloom/glow postprocessing on the fluid output for visual polish
  • WebGL2 render targets with float textures for accurate pressure solving
  • Compositing the fluid simulation as a background, overlay, or texture in a Three.js scene
  • Proper disposal of all render targets and shader programs
Installs
2
First Seen
Aug 30, 2026
three-fluid-simulation — avnehsbhatia/ultraui