How pmndrs/postprocessing works
Project type and purpose
• This is an open-source JavaScript/TypeScript library (“postprocessing”) that extends three.js with a flexible post-processing pipeline.
• Its main purpose is to provide pre-built “Effects” and “Passes” (bloom, antialiasing, depth of field, etc.) that can be composed via an EffectComposer to manipulate the final rendered image in WebGL.
High-level file structure analysis
• Top level
– src/ – the library’s core code, subdivided into modules:
• core (EffectComposer, Timer, Resolution, etc.)
• passes (RenderPass, EffectPass, CopyPass, DepthPass, etc.)
• effects (BloomEffect, SSAOEffect, ToneMappingEffect, etc.)
• materials (shader wrappers + GLSL under materials/glsl/)
• loaders (LUT loaders, SMAA loaders)
• textures (lookup tables, noise, smaa image data)
• utils (helper functions)
• enums (typed constants used across the library)
– demo/ – a standalone frontend showcasing each effect in action (HTML + JS demos + 3D models + assets)
– manual/ – documentation website source (Markdown, CSS/SCSS, JS for the site, layouts, static assets)
– test/ – unit tests mirroring src/ structure to verify each component
– types/, tsconfig.json – TypeScript definitions
– esbuild.js, package.json, CI/CD workflows, config files
Key insights from the README
• The library plugs into three.js by accepting a WebGLRenderer and providing an EffectComposer.
• Effects are implemented by combining Materials (wrapping GLSL shaders) with Pass logic.
• A single-triangle fullscreen pass optimization is applied for performance.
a. Main components
• External dependency: three.js (WebGLRenderer, Scene, Camera)
• Core: EffectComposer
• Passes: RenderPass, EffectPass, ShaderPass, CopyPass, DepthPass, etc.
• Effects: BloomEffect, SSAOEffect, GlitchEffect, ToneMappingEffect, etc.
• Materials + Shaders: shader wrappers + GLSL code under materials/glsl/ and effects/glsl/
• Loaders & Textures: LUT loaders, SMAA loaders, noise textures, lookup tables
• Utilities & Enums: shared helpers, timing, IDs, constant definitions
• Clients: Demo application, Documentation site, Consumer applications
b. Relationships and interactions
– Client instantiates a three.js WebGLRenderer → passed into EffectComposer
– Composer holds an ordered list of Pass objects
– Each Pass:
• may render the scene (RenderPass) or process a texture (EffectPass)
• may own one or more Materials (shaders) and use Textures/Loaders
– Effects are pure shader-based subcomponents that the EffectPass orchestrates
– Utilities and Enums flow into all modules as common dependencies
c. Architectural patterns & principles
– Plugin/composition pattern: Effects and Passes can be registered and chained
– Single-responsibility: each module (core, pass, effect, material, loader) has a well-defined role
– High cohesion: shader code grouped with its material wrapper
– Low coupling: Passes depend only on abstract interfaces (textures, materials, render targets)
d. Key technologies & frameworks
– three.js (WebGLRenderer, Scene, Camera, Texture types)
– esbuild (build script)
– SCSS & static site generator for manual/
– Jest (or similar) for tests
– TypeScript type definitions