Skip to main content

Module bloom

Module bloom 

Source
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 ────▶ output

Each pyramid level is half-resolution, giving a wider, softer halo.

Structs§

BloomParams
Configuration for the bloom pass.
BloomPyramidLevel
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 texture u_texel_size: vec2 — 1/resolution u_direction: vec2 — (1,0) for H, (0,1) for V u_sigma: float — Gaussian sigma in pixels
COMPOSITE_FRAG
GLSL fragment shader source for the bloom composite pass. Expects: u_scene: sampler2D — original scene u_bloom: sampler2D — blurred bloom u_intensity: float — additive blend weight u_dirt: sampler2D — optional lens dirt mask u_dirt_intensity: float
EXTRACT_FRAG
GLSL fragment shader source for the bright-extract pass. Expects: u_scene: sampler2D — full scene color u_emission: sampler2D — emission texture (optional) u_threshold: float u_knee: float u_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 × height RGBA buffer. buffer is RGBA interleaved (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 of 2*size+1 taps.
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 - knee contribute 0, above threshold + knee contribute fully.