Faking Fluid: How Lusion's Screen Effect Runs on a Single Velocity Texture, Recreated in Three.js
Interactive screens that read as fluid simulation no longer need a physics solver: a 1/8-resolution velocity texture and a 9-tap distortion pass produce the same visual on low-end GPUs. That makes this a practical pattern for marketing pages, hero banners, and any WebGL scene where realism comes from clever sampling rather than expensive math.
Lusion's screen fluid effect, where mouse strokes bend, smear, and rainbow-tint a background, runs without any fluid solver. A single 8-bit RGBA texture stores velocity and two ink weights; the scene is sampled nine times along that velocity field to fake refraction and chromatic aberration. The recreation, written in Three.js, keeps the simulation at 1/4 resolution and the velocity field at 1/8, with semi-Lagrangian advection carrying ink each frame and a procedural base of thin concentric rings that make the displacement visible.
The post walks through the full pipeline: velocity channels encoded with a +0.5 offset, brush painting as a line segment with radius mapped to pointer speed, a 9-tap Gaussian blur on the downsampled velocity field, and a distortion pass that adds phase-offset sine stripes for the rainbow edge. After the mouse stops, a 60ms-to-200ms idle logic shuts off external push and lets the ink spread via gradient diffusion, capped by a CFL condition of 0.75 texels per frame. Six practical pitfalls are spelled out, including the 8-bit quantization dead zone that requires a minimum per-frame decay, ping-pong RT swapping, coordinate-system mismatches, dt clamping, resize resets, and linear color-space clears.
The choice of a low-resolution 8-bit velocity field keeps the effect cheap enough for full-frame interactive use, but it forces the developer to solve quantization dead zones and downsampling artifacts; the tradeoff pays off on GPUs where memory bandwidth is scarce.
The illusion depends on the background: thin concentric rings amplify displacement and chromatic aberration, so the same velocity field on a plain color would be invisible. The base image is part of the effect, not just a decorative texture.
The idle behavior (spreading instead of sliding) is a key cue that makes the ink feel like liquid rather than a dragged sprite; without it, residual velocity would make the blob drift like a rigid body.
The whole approach is a post-processing chain that never touches geometry, which means it can be layered onto any existing scene and composed with other passes (Smaa, Fsr) without breaking the render loop.
Best of all is the line that the velocity field isn't computed — it's pushed. Take the whole trick apart and it's an 8-bit texture plus semi-Lagrangian advection, no wonder it runs at full framerate. The quantization dead-zone pitfall is described very concretely: after multiplying data by 0.95, a value smaller than 1/255 gets rounded back up to 1, turning the whole screen gray. You'd never anticipate that kind of problem without actually running it once. One question: the idle logic that starts easing off 60ms after release — on a touchscreen, could the instant the finger lifts be misjudged as stopping? Is there separate handling for touch?