Bloom
glint · Examples · Tutorials · Gallery
Post-processing chain: a neon scene, bright-pass + horizontal blur and vertical blur at quarter size, then composite.
Audio-reactive: it moves with music from a microphone, line-in or a file.

An example in glint, a free live shader editor in the browser: the GLSL code floats over the running picture and recompiles as you type.
The code
4 passes, drawn in this order each frame, in GLSL.
Scene: fragment shader
#version 300 es
precision highp float;
uniform float time;
uniform vec2 resolution;
uniform vec3 spectrum;
in vec2 v_texcoord;
out vec4 fragColor;
float ring(vec2 p, float r, float w) { return smoothstep(w, 0.0, abs(length(p) - r)); }
void main() {
vec2 p = (gl_FragCoord.xy - 0.5 * resolution) / resolution.y;
vec3 col = vec3(0.01, 0.01, 0.02);
for (int i = 0; i < 6; i++) {
float fi = float(i);
vec2 o = 0.3 * vec2(sin(time * 0.5 + fi * 1.1), cos(time * 0.7 + fi * 1.7));
vec3 c = 0.5 + 0.5 * cos(fi + vec3(0.0, 2.0, 4.0));
col += c * ring(p - o, 0.08 + 0.03 * sin(time + fi) + spectrum.x * 0.1, 0.006) * 2.0;
}
// A thin horizon line.
col += vec3(1.0, 0.4, 0.1) * smoothstep(0.004, 0.0, abs(p.y + 0.35)) * 1.5;
fragColor = vec4(col, 1.0);
}Blur H: fragment shader
#version 300 es
precision highp float;
uniform sampler2D pass0;
uniform vec2 resolution;
uniform float threshold;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec3 sum = vec3(0.0);
float wsum = 0.0;
for (int i = -8; i <= 8; i++) {
float w = exp(-float(i * i) / 18.0);
vec3 c = texture(pass0, v_texcoord + vec2(float(i) / resolution.x, 0.0)).rgb;
sum += max(c - threshold, 0.0) * w; // only what's brighter than the threshold blooms
wsum += w;
}
fragColor = vec4(sum / wsum, 1.0);
}Blur V: fragment shader
#version 300 es
precision highp float;
uniform sampler2D prevPass;
uniform vec2 resolution;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec3 sum = vec3(0.0);
float wsum = 0.0;
for (int i = -8; i <= 8; i++) {
float w = exp(-float(i * i) / 18.0);
sum += texture(prevPass, v_texcoord + vec2(0.0, float(i) / resolution.y)).rgb * w;
wsum += w;
}
fragColor = vec4(sum / wsum, 1.0);
}Composite: fragment shader
#version 300 es
precision highp float;
uniform sampler2D pass0;
uniform sampler2D prevPass;
uniform float intensity;
in vec2 v_texcoord;
out vec4 fragColor;
void main() {
vec3 scene = texture(pass0, v_texcoord).rgb;
vec3 glow = texture(prevPass, v_texcoord).rgb;
vec3 c = scene + glow * intensity;
c = 1.0 - exp(-c * 1.2); // exposure tone map
fragColor = vec4(pow(c, vec3(0.9)), 1.0);
}More Starters examples
Reaction–diffusion · Game of Life · Instanced cubes · Wireframe waves · Terrain flyover · Dal Platinum · Bass rings · Radial spectrum