Field into a 3D texture
Every frame the velocity field is packed into an RGBA8 volume: red is the field, blue is a distance field used to shade the spheres, alpha is unused.
Nineteen velocity directions, 160,000 cells, forty solid spheres. Drag to orbit the box — the haze is the flow field, integrated along every ray.
160k fluid cells around 40 solid spheres. Drag on the canvas to orbit; the haze is speed (or pressure / vorticity), the balls are shaded from a distance field stored in the same 3D texture.
The two-dimensional pages use nine directions per cell. Here each cell carries nineteen distribution values: one at rest, six along the axes, and twelve along the face diagonals. The step is the same idea as before — relax towards a local equilibrium, then move each value to the neighbouring cell in its own direction — just with more directions and a third axis.
Solid spheres are handled by bounce-back: when a streaming direction would enter a solid cell, the value is reflected back the way it came. That gives a no-slip wall without any mesh, which is the reason a random packing like this needs no geometry work at all.
Every frame the velocity field is packed into an RGBA8 volume: red is the field, blue is a distance field used to shade the spheres, alpha is unused.
The fragment shader intersects the box, then marches 24–96 samples through the volume, accumulating colour with a front-to-back alpha blend.
When a ray reaches a cell inside a sphere, the distance field gives a normal in three extra texture reads and the ray stops with a shaded surface. No impostor meshes, no second pass.
The grid is coarse enough that individual spheres are only a few cells across, the domain is periodic-looking but actually walled, and there is no turbulence model — at this Reynolds number the wakes are already unsteady and only partially resolved.
What survives all that is the qualitative picture: flow finds channels through a packing, wakes form behind obstacles, pressure builds on upstream faces. Those are the features people actually look for when they first see a porous-medium simulation, and they cost a browser tab here.
Yes — 56×32×32 cells, nineteen velocity directions (D3Q19), solid spheres resolved as bounce-back walls. The image is a volume render: every pixel marches a ray through the box and accumulates the field along the way.
That is the rendering, not the physics. A volume render integrates the field along each ray, so dense regions become opaque and thin ones become haze. There is no surface to draw — except the spheres, which are shaded from a distance field.
A D3Q19 step in JavaScript costs roughly two hundred bytes of work per cell per step. This grid is about 160,000 cells; going to 128³ would be eight times slower and would not run at interactive rates on a laptop.
Switch to vorticity and watch the wakes behind individual spheres. Switch to pressure and look for the high-pressure patch on each upstream face. The spheres are randomly packed, so the flow has to find its way through — that is the same problem a porous medium solver faces.