Expand description
Bloom post-processing pass.
Implements a multi-level Gaussian bloom using a luminance threshold extract followed by a separable ping-pong blur pyramid. The result is additively blended onto the scene framebuffer.
§Pipeline
scene_color + scene_emission
── extract bright pixels ──▶ bright_fbo
── H blur (radius 1) ──────▶ blur_h[0]
── V blur (radius 1) ──────▶ blur_v[0]
── H blur (radius 2) ──────▶ blur_h[1] ← pyramid level 1
── V blur (radius 2) ──────▶ blur_v[1]
─── additive composite ────▶ outputEach pyramid level is half-resolution, giving a wider, softer halo.
Structs§
- Bloom
Params - Configuration for the bloom pass.
- Bloom
Pyramid Level - Descriptor for one level of the bloom pyramid.
Constants§
- BLUR_
FRAG - GLSL fragment shader source for the separable Gaussian blur pass.
Expects:
u_texture: sampler2D — input textureu_texel_size: vec2 — 1/resolutionu_direction: vec2 — (1,0) for H, (0,1) for Vu_sigma: float — Gaussian sigma in pixels - COMPOSITE_
FRAG - GLSL fragment shader source for the bloom composite pass.
Expects:
u_scene: sampler2D — original sceneu_bloom: sampler2D — blurred bloomu_intensity: float — additive blend weightu_dirt: sampler2D — optional lens dirt masku_dirt_intensity: float - EXTRACT_
FRAG - GLSL fragment shader source for the bright-extract pass.
Expects:
u_scene: sampler2D — full scene coloru_emission: sampler2D — emission texture (optional)u_threshold: floatu_knee: floatu_emission_weight: float
Functions§
- compute_
pyramid - Compute the pyramid levels for a given base resolution and params.
- cpu_
bloom - Full CPU bloom simulation (extract → H blur → V blur → composite). Returns a new RGBA buffer with bloom composited onto the input.
- cpu_
blur_ h - Simulate one horizontal Gaussian blur pass on a flat
width × heightRGBA buffer.bufferisRGBAinterleaved (stride = width * 4). - cpu_
blur_ v - Simulate one vertical Gaussian blur pass on a flat RGBA buffer.
- extract_
bloom_ pixel - Extract the bloom contribution from a pixel with a soft threshold.
Returns
(r, g, b)with the threshold applied. - gaussian_
kernel - Compute a 1D Gaussian kernel of given
radius(standard deviation). Returns weights summing to 1 for a kernel of2*size+1taps. - linear_
gaussian_ kernel - Separable Gaussian weights optimised for bilinear texture fetches.
Returns
(offsets, weights)for a half-kernel (center + positive taps). Linear sampling combines two adjacent texels, halving the tap count. - luminance
- Compute perceptual luminance from linear RGB.
- normalise_
pyramid_ weights - Normalise pyramid weights so they sum to 1.
- soft_
threshold - Soft-threshold a luminance value with knee falloff.
Pixels below
threshold - kneecontribute 0, abovethreshold + kneecontribute fully.