tsl-post-processing — Claude Code rule: TSL post-processing for Three.js
A reference rule for TSL post-processing in Three.js: chain effects onto postProcessing.outputNode instead of stacking EffectComposer passes.
MIT ★ 4,719 updated 2026-10-24
.claude/rules/tsl-post-processing.mdWhat tsl-post-processing does
The rule makes TSL (Three.js Shading Language) the way your agent builds post-processing for WebGPU and WebGL scenes. Effects go onto postProcessing.outputNode rather than into a pass list, and the file gives the signature of each one: bloom, dof, chromaticAberration, ssr, ao, traa, fxaa, smaa, lut3D, film and the rest.
Short snippets show the shape of a chain. Take the beauty texture from scenePass.getTextureNode(), wrap it in hue and saturation, close with bloom. The depth of field example pulls getDepthNode() and passes focus distance, focal length and bokeh scale.
Five house rules sit at the end, and one matters most. Post-processing skips WebGL's own anti-aliasing, so fxaa or smaa has to close the chain or edges crawl. The file also sets the classic EffectComposer setup against this approach and points at the postprocessing package from Poimandres as an alternative, added with npm install postprocessing.
What it helps with
- Chain bloom with depth of field using TSL nodes
- Move an existing scene off
EffectComposerand ontopostProcessing.outputNode - Get anti-aliasing back after turning post-processing on
- Look up what arguments
doforanamorphicexpect - Add colour grading through
lut3Dbefore the frame is written
Example prompts for the agent
- Build the post-processing chain in TSL with bloom and depth of field on
postProcessing.outputNode - Rewrite this
EffectComposerpass list as TSL nodes and show me the difference - Edges look jagged after post-processing, put
fxaaat the end of the chain
How to install tsl-post-processing
Manually: put the files in place
.claude/rules/tsl-post-processing.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/tsl-post-processing.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/tsl-post-processing.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/tsl-post-processing.mdManually: put the files in place
.clinerules/tsl-post-processing.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about tsl-post-processing
How to install tsl-post-processing in Claude Code?
Place the rule file at .claude/rules/tsl-post-processing.md inside your project. Claude then reads it as a project rule.
What does tsl-post-processing do?
It gives the agent a reference for TSL effects in Three.js: signatures, chain examples and the order to build them in. The agent leans on it while writing WebGPU or WebGL post-processing code.
How is TSL different from EffectComposer?
EffectComposer takes passes one at a time and renders through composer.render(). With TSL you build a node tree and hand it to postProcessing.outputNode.
Source text
tsl-post-processing.md · MIT
# TSL Post-Processing
Modern post-processing using TSL (Three.js Shading Language) for WebGPU and WebGL.
## TSL Post-Processing Setup
```javascript
import { pass, bloom, gaussianBlur, grayscale } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
// Chain effects
postProcessing.outputNode = bloom(grayscale(beauty), 1, 0.4, 0.85);
```
## Available Effects
| Effect | Signature |
|--------|-----------|
| After Image | `afterImage(node, damp)` |
| Anamorphic Flare | `anamorphic(node, threshold, scale, samples)` |
| Bloom | `bloom(node, strength, radius, threshold)` |
| Box Blur | `boxBlur(textureNode, options)` |
| Chromatic Aberration | `chromaticAberration(node, strength, center, scale)` |
| Denoise | `denoise(node, depthNode, normalNode, camera)` |
| Depth of Field | `dof(node, viewZ, focusDistance, focalLength, bokehScale)` |
| Dot Screen | `dotScreen(node, angle, scale)` |
| Film Grain | `film(inputNode, intensity, uv)` |
| FXAA | `fxaa(node)` |
| Gaussian Blur | `gaussianBlur(node, direction, sigma, options)` |
| Grayscale | `grayscale(color)` |
| Hash Blur | `hashBlur(textureNode, blurAmount, options)` |
| LUT Grading | `lut3D(node, lut, size, intensity)` |
| Motion Blur | `motionBlur(inputNode, velocity, samples)` |
| Outline | `outline(scene, camera, params)` |
| RGB Shift | `rgbShift(node, amount, angle)` |
| Sepia | `sepia(color)` |
| SMAA | `smaa(node)` |
| Sobel | `sobel(node)` |
| SSR | `ssr(colorNode, depthNode, normalNode, metalness, roughness, camera)` |
| SSGI | `ssgi(beautyNode, depthNode, normalNode, camera)` |
| AO | `ao(depthNode, normalNode, camera)` |
| Transition | `transition(nodeA, nodeB, mixTexture, ratio, threshold, useTexture)` |
| TRAA | `traa(beautyNode, depthNode, velocityNode, camera)` |
## Common Patterns
### Bloom
```javascript
import { pass, bloom } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
postProcessing.outputNode = bloom(beauty, 1, 0.4, 0.85);
// Parameters: node, strength, radius, threshold
```
### Gaussian Blur
```javascript
import { gaussianBlur, pass } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
postProcessing.outputNode = gaussianBlur(beauty, 4);
// Parameters: node, sigma
```
### Color Grading Pipeline
```javascript
import { pass, grayscale, saturation, hue, bloom } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
// Chain multiple effects
const graded = saturation(hue(beauty, 0.1), 1.2);
const final = bloom(graded, 0.5, 0.4, 0.9);
postProcessing.outputNode = final;
```
### Depth of Field
```javascript
import { pass, dof } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
const depth = scenePass.getDepthNode();
postProcessing.outputNode = dof(
beauty,
depth,
5, // focusDistance
0.02, // focalLength
0.025 // bokehScale
);
```
## TSL vs EffectComposer
### EffectComposer (WebGL Traditional)
```javascript
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
composer.addPass(new UnrealBloomPass(resolution, strength, radius, threshold));
// In render loop
composer.render();
```
### TSL Post-Processing (Modern)
```javascript
import { pass, bloom } from 'three/tsl';
const scenePass = pass(scene, camera);
const beauty = scenePass.getTextureNode();
postProcessing.outputNode = bloom(beauty, 1, 0.4, 0.85);
```
## Best Practices
1. **Tone Mapping**: When using postprocessing, set `renderer.toneMapping = NoToneMapping` and add tone mapping as last effect
2. **Precision**: Use `HalfFloatType` for high precision frame buffers
3. **Anti-Aliasing**: WebGL AA is bypassed with postprocessing; add FXAA/SMAA at the end
4. **Performance**: Combine multiple effects into single pass when possible
5. **Order**: RenderPass always first, AA always last
## Alternative: pmndrs/postprocessing
High-performance post-processing library from Poimandres ecosystem:
- Better performance than built-in EffectComposer
- Optimized effects
- Better selective bloom support
```bash
npm install postprocessing
```
## References
- [Three.js Examples - Post-Processing](https://threejs.org/examples/?q=postprocessing)
- [pmndrs/postprocessing](https://github.com/pmndrs/postprocessing)
© zebbern · MIT · zebbern/claude-code-guide