Bloom
Look at a bright lamp at night, or the sun through a window: the light seems to spill over its edges. Real lenses and eyes scatter a little of every bright source into its surroundings. Bloom imitates that by adding a blurred copy of the brightest pixels back onto the image. It is the effect that makes neon signs, muzzle flashes, magic spells and sci-fi panels look like they emit light instead of just being painted in a bright color.
Bloom only works well with HDR: the scene has to be rendered with values above 1.0, so the shader can tell a light (intensity 8) from a white wall (intensity 0.9). In an 8-bit target both are clamped to 1.0 and look the same.
The pipeline
| Step | Pass | Target |
|---|---|---|
| 1 | render the scene with emissive values above 1 | HDR (HalfFloatType), full resolution |
| 2 | bright pass: keep only what is above a threshold | half resolution |
| 3 | blur chain: downsample and blur at several sizes (half, quarter, eighth…) | one small target per level |
| 4 | composite: scene + strength × sum of the blurred levels | HDR |
| 5 | tone map and encode to sRGB | the screen |
The order matters. Bloom is added before tone mapping, in linear HDR light, because that is where light adds physically. Tone mapping afterwards squeezes the glow and the source into the displayable range together.
The bright pass
A hard cutoff (lum > threshold ? color : 0) makes glows pop on and off as an object's brightness crosses the threshold. A soft version subtracts the threshold and keeps the color's hue:
vec3 brightPass(vec3 c, float threshold) {
float lum = dot(c, vec3(0.2126, 0.7152, 0.0722)); // luminance (Rec. 709 weights)
float keep = max(lum - threshold, 0.0) / max(lum, 1e-4);
return c * keep;
}Many engines add a "knee" to the curve so the transition is even softer, and some skip the threshold entirely (Unreal's and Unity's physically based modes blend a small fraction of everything, which looks more like a real lens).
Several blur sizes
A single blur gives either a tight halo or a big haze, never both. Real glare has a bright core and a long, faint tail. Summing blurs at several resolutions approximates that tail cheaply: each level is half the size of the previous one, so its blur covers twice the screen distance for the same cost.
Bloom by hand
This example builds the whole pipeline from the Render Targets and Blur lessons: an HDR scene target, a bright pass into half resolution, three blur levels, and a composite with ACES-style tone mapping. Move the pointer horizontally to change the bloom strength; at the far left it is off.
<style>body { margin: 0; background: #000 } canvas { display: block }</style>
<script type="module">
import * as THREE from 'three';
const renderer = new THREE.WebGLRenderer();
renderer.setSize(innerWidth, innerHeight);
document.body.appendChild(renderer.domElement);
const size = renderer.getDrawingBufferSize(new THREE.Vector2());
// --- HDR scene: dim lighting, very bright emissive objects ---
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x05060a);
const camera = new THREE.PerspectiveCamera(45, innerWidth / innerHeight, 0.1, 50);
camera.position.set(0, 1.5, 7);
camera.lookAt(0, 0.3, 0);
scene.add(new THREE.HemisphereLight(0x8899bb, 0x111111, 0.4));
const floor = new THREE.Mesh(new THREE.PlaneGeometry(20, 20), new THREE.MeshStandardMaterial({ color: 0x222228, roughness: 0.4 }));
floor.rotation.x = -Math.PI / 2;
floor.position.y = -0.8;
scene.add(floor);
const glowing = [];
const colors = [0xff3060, 0x30ff90, 0x3080ff, 0xffaa20];
colors.forEach((c, i) => {
const mesh = new THREE.Mesh(new THREE.TorusGeometry(0.45, 0.08, 16, 64),
new THREE.MeshStandardMaterial({ color: 0x000000, emissive: c, emissiveIntensity: 6 })); // HDR: way above 1
mesh.position.x = (i - 1.5) * 1.6;
const lamp = new THREE.PointLight(c, 3, 4);
mesh.add(lamp);
scene.add(mesh);
glowing.push(mesh);
});
// --- targets ---
const hdr = { type: THREE.HalfFloatType };
const sceneRT = new THREE.WebGLRenderTarget(size.x, size.y, hdr);
const levels = [2, 4, 8].map((div) => {
const w = Math.max(1, Math.floor(size.x / div)), h = Math.max(1, Math.floor(size.y / div));
return { a: new THREE.WebGLRenderTarget(w, h, hdr), b: new THREE.WebGLRenderTarget(w, h, hdr), w, h };
});
// --- passes ---
const vertexShader = `varying vec2 vUv; void main() { vUv = uv; gl_Position = vec4(position.xy, 0.0, 1.0); }`;
const pass = (fragmentShader, uniforms) => new THREE.ShaderMaterial({ vertexShader, fragmentShader, uniforms });
const brightMat = pass(/* glsl */ `
uniform sampler2D tInput; uniform float uThreshold; varying vec2 vUv;
void main() {
vec3 c = texture2D(tInput, vUv).rgb;
float lum = dot(c, vec3(0.2126, 0.7152, 0.0722));
gl_FragColor = vec4(c * max(lum - uThreshold, 0.0) / max(lum, 1e-4), 1.0);
}`, { tInput: { value: sceneRT.texture }, uThreshold: { value: 1.0 } });
const copyMat = pass(`uniform sampler2D tInput; varying vec2 vUv; void main() { gl_FragColor = texture2D(tInput, vUv); }`,
{ tInput: { value: null } });
const blurMat = pass(/* glsl */ `
uniform sampler2D tInput; uniform vec2 uStep; varying vec2 vUv;
void main() {
vec3 c = texture2D(tInput, vUv).rgb * 0.20416;
c += (texture2D(tInput, vUv + uStep * 1.40733).rgb + texture2D(tInput, vUv - uStep * 1.40733).rgb) * 0.30401;
c += (texture2D(tInput, vUv + uStep * 3.29421).rgb + texture2D(tInput, vUv - uStep * 3.29421).rgb) * 0.09391;
gl_FragColor = vec4(c, 1.0);
}`, { tInput: { value: null }, uStep: { value: new THREE.Vector2() } });
const compositeMat = pass(/* glsl */ `
uniform sampler2D tScene, tBloom0, tBloom1, tBloom2; uniform float uStrength; varying vec2 vUv;
vec3 acesFitted(vec3 x) { // Narkowicz 2015 fit of the ACES curve
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void main() {
vec3 bloom = texture2D(tBloom0, vUv).rgb + texture2D(tBloom1, vUv).rgb + texture2D(tBloom2, vUv).rgb;
vec3 hdr = texture2D(tScene, vUv).rgb + bloom * uStrength; // add in linear HDR
gl_FragColor = vec4(acesFitted(hdr * 0.8), 1.0); // then tone map
#include <colorspace_fragment>
}`, {
tScene: { value: sceneRT.texture }, uStrength: { value: 0.5 },
tBloom0: { value: levels[0].a.texture }, tBloom1: { value: levels[1].a.texture }, tBloom2: { value: levels[2].a.texture },
});
const quad = new THREE.Mesh(new THREE.PlaneGeometry(2, 2));
const postScene = new THREE.Scene();
postScene.add(quad);
const postCamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
function draw(material, target) {
quad.material = material;
renderer.setRenderTarget(target);
renderer.render(postScene, postCamera);
}
addEventListener('pointermove', (e) => { compositeMat.uniforms.uStrength.value = Math.max(0, e.clientX / innerWidth - 0.05) * 1.2; });
renderer.setAnimationLoop((ms) => {
glowing.forEach((m, i) => { m.rotation.set(ms / 1200 + i, ms / 1700, 0); m.position.y = Math.sin(ms / 700 + i) * 0.3 + 0.3; });
renderer.setRenderTarget(sceneRT);
renderer.render(scene, camera);
draw(brightMat, levels[0].a); // 1. bright pass, half resolution
levels.forEach((lvl, i) => {
if (i > 0) { copyMat.uniforms.tInput.value = levels[i - 1].a.texture; draw(copyMat, lvl.a); } // 2. downsample
blurMat.uniforms.tInput.value = lvl.a.texture; // 3. blur this level: A -> B -> A
blurMat.uniforms.uStep.value.set(1 / lvl.w, 0);
draw(blurMat, lvl.b);
blurMat.uniforms.tInput.value = lvl.b.texture;
blurMat.uniforms.uStep.value.set(0, 1 / lvl.h);
draw(blurMat, lvl.a);
});
draw(compositeMat, null); // 4 + 5. composite, tone map, sRGB
});
</script>Notice that the floor picks up the glow too: the floor's reflections of the rings are bright enough to pass the threshold. That is HDR doing its job. Lower emissiveIntensity to 1.0 and the bloom almost vanishes, because nothing is brighter than the threshold any more.
Bloom with EffectComposer
Three.js ships the same pipeline as ready-made passes in three/addons/postprocessing/. EffectComposer manages the ping-pong targets (HalfFloat by default), RenderPass draws the scene, UnrealBloomPass does the bright pass and a five-level blur chain, and OutputPass applies the renderer's tone mapping and output color space at the end.
<style>body { margin: 0; background: #000 } canvas { display: block }</style>
<script type="module">
import * as THREE from 'three';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
import { OutputPass } from 'three/addons/postprocessing/OutputPass.js';
const renderer = new THREE.WebGLRenderer();
renderer.setSize(innerWidth, innerHeight);
renderer.toneMapping = THREE.ACESFilmicToneMapping; // used by OutputPass
document.body.appendChild(renderer.domElement);
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(50, innerWidth / innerHeight, 0.1, 50);
camera.position.set(0, 0, 6);
// a ring of emissive cubes
const group = new THREE.Group();
for (let i = 0; i < 16; i++) {
const hue = i / 16;
const cube = new THREE.Mesh(new THREE.BoxGeometry(0.3, 0.3, 0.3),
new THREE.MeshBasicMaterial({ color: new THREE.Color().setHSL(hue, 1, 0.5).multiplyScalar(i % 4 === 0 ? 5 : 1) }));
const a = (i / 16) * Math.PI * 2;
cube.position.set(Math.cos(a) * 2, Math.sin(a) * 2, 0);
group.add(cube);
}
scene.add(group);
const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
const bloom = new UnrealBloomPass(new THREE.Vector2(innerWidth, innerHeight), 0.8, 0.3, 0.9); // strength, radius, threshold
composer.addPass(bloom);
composer.addPass(new OutputPass());
renderer.setAnimationLoop((ms) => {
group.rotation.z = ms / 3000;
group.children.forEach((c, i) => c.rotation.set(ms / 900 + i, ms / 1100, 0));
composer.render(); // instead of renderer.render
});
</script>Every fourth cube's color is multiplied by 5, which pushes it above the threshold of 0.9; the others stay below it and do not glow. That is the usual way to control bloom in a game: not with a mask, but by making things that should glow brighter than 1, through emissive intensity or HDR colors (Unity's HDR color picker "Intensity", Unreal's emissive multiplier, Godot's emission_energy_multiplier).
In engines
| Engine | Where | Notes |
|---|---|---|
| Unity URP | Volume → Bloom override | Threshold, Intensity, Scatter; enable HDR in the URP asset so emissives can exceed 1 |
| Unreal Engine | Post Process Volume → Lens → Bloom | Standard (mip chain) or Convolution (FFT, for realistic lens glare) |
| Godot 4 | WorldEnvironment → Glow |
levels 1–7 like the mip chain here; blend modes Additive, Screen, Softlight… |
Pitfalls
- Bloom on everything turns the image into a soft mess. Keep the threshold at or above 1 and make emissives genuinely bright.
- Flicker on small, bright pixels (specular sparkles, thin emissive lines) because they appear and disappear between frames. A better downsample filter (13-tap, with a "Karis average" on the first level) or temporal anti-aliasing before bloom calms it down.
- Bloom after tone mapping (on LDR colors) makes white walls glow and real lights not; it is the classic sign of an LDR pipeline.
Test yourself
Why does bloom need an HDR (floating-point) scene target?
- Float textures blur faster
- So the bright pass can tell real light sources (values above 1) from merely white surfaces
- Because sRGB can't be blurred
- HDR targets have built-in bloom
In what order should bloom and tone mapping run?
- Tone map, then add bloom
- Add bloom in linear HDR, then tone map
- They are independent
- Bloom replaces tone mapping
What does the threshold parameter of UnrealBloomPass control?
- The blur radius
- The minimum brightness a pixel needs to contribute to the bloom
- The number of mip levels
- The output color space