Post-processing
Quick answer
This tutorial explains why post-processing costs one full-screen render per pass and how to keep the chain short. It builds an EffectComposer with RenderPass, UnrealBloomPass and a mandatory OutputPass, then rescales both renderer and composer on resize with a lower composer pixel ratio. It describes enabling passes selectively, avoiding repeated render-target rebuilds and replacing MSAA with SMAAPass. Readers can add bloom and tone mapping without a dark image or a frame-rate collapse.
Key points
- Add RenderPass first and OutputPass last in the EffectComposer chain.
- Set composer.setPixelRatio lower than the renderer for cheaper effect buffers.
- Skip passes with pass.enabled instead of rebuilding the whole chain.
Example
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 size = new THREE.Vector2(
renderer.domElement.clientWidth,
renderer.domElement.clientHeight
);
const composer = new EffectComposer(renderer);
composer.setSize(size.x, size.y);
composer.addPass(new RenderPass(scene, camera));
const bloom = new UnrealBloomPass(size, 0.55, 0.4, 0.82);
composer.addPass(bloom);
composer.addPass(new OutputPass());
renderer.setAnimationLoop(function () {
composer.render(); // 不再直接 renderer.render
});function resize() {
const w = renderer.domElement.clientWidth;
const h = renderer.domElement.clientHeight;
camera.aspect = w / h;
camera.updateProjectionMatrix();
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.setSize(w, h, false);
composer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
composer.setSize(w, h);
}
window.addEventListener('resize', resize);
resize();
Notes
- Without OutputPass the color space is not converted and the final image looks dark.
- MSAA no longer applies once a composer is used, so add SMAAPass or FXAA.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Post-processing. https://www.jingweizhi.com/en/three/tutorials/post-processing.html (accessed 2026-11-03).