Expand description
Blur-pyramid GPU pipeline.
Builds the 3-level cumulative Gaussian blur (Blur1 → Blur2 → Blur3) that
MD2 user comp shaders sample via GetBlur1/2/3. Each level is the
previous level + one more separable Gaussian pass, so the effective σ
grows ~quadratically: Blur1 is mildly soft, Blur3 is markedly so.
§Pipeline shape
Each blur level renders at half the previous level’s resolution: Blur1 = ½ render, Blur2 = ¼, Blur3 = ⅛. Per level we do two fragment-shader passes (separable Gaussian):
- Horizontal: read from the previous-level texture (Blur0 =
render_textureat full res), write to that level’sblurN_scratch_texture(already at the downsampled resolution). The vertex viewport defaults to the destination texture’s size, so the read happens via the hardware bilinear sampler — implicit downsample. - Vertical: read from
blurN_scratch_texture, write to that level’sblurN_texture(same resolution).
After the third level, the three blur textures hold progressively
softer copies of the warp pass output, ready to be bound into the
comp pass’s bind group at bindings 3/4/5. User shaders’ UV-space
GetBlur1/2/3(uv) sample with the same normalised UV the comp
pass already uses — the smaller texture is transparent to the
caller because the bilinear sampler upscales at sample time.
The shader itself is fixed at a 9-tap kernel for WGSL-compiler-
friendly unrolling; the per-pass texel_size uniform tracks the
source texture’s resolution so each tap walks one source-texel
regardless of which level we’re at.
Structs§
- Blur
Pipeline - Drives the 6 blur passes (3 levels × H+V). One pipeline, six bind groups — each pass needs its own bind group because the source texture changes between passes.
- Blur
Uniforms 🔒
Constants§
- SIGMA_
BLUR1 🔒 - Sigmas (in texels) for each blur level’s H+V pass. Each level reads from the previous one, so the cumulative σ grows like sqrt(Σ σ²). The values below give visually distinct levels: Blur1 just-soft, Blur2 noticeably hazy, Blur3 strong halos — close to what MD2 presets expect.
- SIGMA_
BLUR2 🔒 - SIGMA_
BLUR3 🔒