Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit61a33237e0

README.md

fluid_narrow_filter

The body of one axis of the separable narrow-range depth filter that turns a splat-rasterized particle depth buffer into a continuous liquid surface.

A plain blur over particle depth smears the silhouette into whatever is behind it, because the depth values on either side of an edge are far apart and a mean lands between them. The narrow-range filter clamps every neighbour into a band around the centre depth first, so taps from a different surface contribute the centre's own value rather than dragging the average across the gap. Interior bumps — the reason a pile of spheres reads as spheres rather than as liquid — are inside the band and average away.

The radius scales with 1/z, so the filter covers the same world-space width at every distance and a surface does not visibly change character as the camera pulls back.

Using it

The including shader declares the axis and includes this body:

const AXIS: vec2<i32> = vec2<i32>(1, 0);
#include "~.computeShaders.fluid_narrow_filter"

It expects these bindings, which the including .computeShader declares:

bindingkindholds
fpbuffer, read, vec4<f32>[0] = (projScale × smoothing width, max radius in pixels, band, 0)
srctexture2dthe depth field to filter
dststorage2d, r32fthe filtered depth field

Running it twice — once per axis, ping-ponging through two targets — gives the 2D filter at 2N taps instead of N².