Skip to content

Reality Engine / Fluids

A pond you can drop a rock into.

A 5.76 m x 5.76 m pond solved as a shallow-water heightfield on a 96 x 96 grid. A wooden sphere (600 kg/m³) floats; a steel one (7850 kg/m³) sinks. Each splash injects a ripple that spreads through the damped 2D wave equation and decays. Everything below is rendered from that one solver - pure C#, SI units, no game engine.

Shallow-water heightfield Buoyancy + drag coupling Fresnel water shader BCL-only, AOT-clean
96 x 96solver grid
0.06 mcell size
0.60 mrest depth
c = √(g·h)wave speed

Rendered evidence

Four views of the same solver step

Two beauty passes and two diagnostic fields, all rendered offline to looping GIF.

Beauty render: a wooden sphere floating and a steel sphere sinking on a rippling pond.

Fresnel water, buoyant spheres

Schlick-Fresnel reflectance (IOR 1.33) blended against a Beer-Lambert depth-absorbed pond bed, with sun glint on the ripple crests. Linear-light throughout, ACES tone-mapped at the byte write.

384 x 320 · 40 frames · 30 fps
Four-quadrant debug view: height map, velocity field, turbidity, and force vectors.

Four-quadrant solver telemetry

Clockwise from top-left: surface height map, velocity-field magnitude, turbidity and depth colour, then buoyancy (green) and drag (orange) force vectors drawn on each body in real newtons.

384 x 320 · 30 frames · SI units
Top-down height field showing wave crests and troughs spreading from two impact points.

Wave-interference heightfield

Top-down height ramp - blue troughs, red crests - as the damped 2D wave equation carries each splash outward and the two ripple trains meet and interfere across the pond.

360 x 360 · top-down · +/-14 mm
Top-down velocity magnitude field with cyan energy radiating from two disturbance points.

Velocity-magnitude field

The same step read as surface flux: cyan marks where water is moving fastest. Energy peaks at each impact, then fans out along the wavefronts and bleeds off through per-step damping.

360 x 360 · top-down · 0 - 0.45 m/s

How it works

One small solver, fully auditable

The pond is a heightfield stepped by the shallow-water wave equation with a CFL-safe sub-step (4 per frame) and a 0.995 per-step damping standing in for viscous loss. Each sphere carries its own buoyancy and quadratic-drag integration; when it breaks the surface it stamps a ripple back into the field, so the water and the bodies are coupled both ways.

The physics and shading are hand-rolled in double precision and narrowed to bytes only at the final GIF encode. It leans on OnlyCSharp 1.7 (the frozen library) for the GIF encoder, fluid-mechanics formulas and noise - nothing outside the .NET base class library. A five-check self-test holds the physics honest: wood floats, steel sinks, wave energy decays (10.83 -> 3.64 J), no NaN after 2000 coupled steps, and the wooden sphere settles at the surface.