A full-page GPU fluid simulation drawn as a grid of tiny line segments. Your cursor stirs it, and each segment turns a rainbow colour keyed to the direction it flows, then fades back to grey dots as the fluid settles.
This ports the page background on rgbjoy.com. The site runs a small Navier–Stokes fluid solver with [gpu-io](https://github.com/amandaghassaei/gpu-io) (MIT, Amanda Ghassaei). The fragment shaders here are the site's own, verbatim.
The velocity field lives in a two-channel float texture at 1/8 of the viewport, with linear filtering. Each frame runs advect → wall (zero the normal velocity at the edges) → divergence → 3 Jacobi pressure iterations (pressure is kept between frames as a warm start) → gradient subtraction → wall → damping (×0.985, with anything under 0.015 snapped to zero so the field fully settles).
Every mouse move stamps a 30px round-capped segment along the pointer's path. Inside it, the pointer delta is added with a 1 − r² falloff ×2, and the result is capped at 30. On load, five curved strokes swirl out of the centre. On touch or no-hover devices, a random curved stroke (8–14 short segments with a jittered heading) fires every 1.7–3.9s instead.
The field is not drawn as a picture. It is drawn as GL lines: one per 14px grid point, from the point to the point plus velocity ×2.5, with the line position computed in the vertex shader from gl_VertexID. The fragment shader colours each line from the velocity under it. At rest it is grey (0.35). As energy (|v|/6) rises it blends via smoothstep into an [Inigo Quilez cosine palette](https://iquilezles.org/articles/palettes/) indexed by heading + time·0.06 + energy·0.25, with a gain of 1.25. So a swirl reads as a ring of hues keyed to direction, and the colour slowly cycles over time.
The small parts of gpu-io the shaders depend on are re-implemented in about 100 lines of plain WebGL2: fullscreen passes, ping-pong buffers, the round-capped segment stamp (a triangle fan of 18 cap segments, which copies the layer first so the rest of the field is kept), and the vertex-ID line draw. The textures use half floats (RG16F) so linear filtering works without extra extensions. Only the dark theme is ported (the site's light theme uses rest 0.68, gain 0.72, on white). Self-contained: no external scripts, fonts, or images.
This is a complete, self-contained HTML document — copy it verbatim rather than reconstructing it. Markdown version: https://fx.statico.io/effects/rgbjoy-fluid-field.md. Full writeup and live preview: https://fx.statico.io/demos/rgbjoy-fluid-field.
Effect originally seen on rgbjoy (https://rgbjoy.com/) — credit to Tom Fletcher (rgbjoy). This is an independent recreation built from scratch for educational use; no proprietary source code was copied. Released under the Unlicense.
Terms used above are defined in the glossary. See also the site map, AGENTS.md and llms.txt.
Move your mouse. The fluid underneath the page stirs, and every grid line takes its colour from the direction it flows.