Skip to main content
rule CX Codex

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

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/rules/tsl-post-processing.md
Open on GitHub

What 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 EffectComposer and onto postProcessing.outputNode
  • Get anti-aliasing back after turning post-processing on
  • Look up what arguments dof or anamorphic expect
  • Add colour grading through lut3D before 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 EffectComposer pass list as TSL nodes and show me the difference
  • Edges look jagged after post-processing, put fxaa at the end of the chain

How to install tsl-post-processing

Manually: put the files in place

.claude/rules/tsl-post-processing.md

The paths frontmatter field limits the files

Step 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

Similar IDE rules

All IDE rules for Game dev and 3D: Unity, Unreal, Godot, Blender →

From the same set86

The whole set →
lighting-shadows-advanced The lighting-shadows-advanced rule covers lighting and shadow settings in Three.js with rendering cost in mind. Use it when tuning a scene with several lights or shadow maps. CX Codex +1 ★ 4,719repo stars migration-checklist migration-checklist teaches the agent how to migrate code when Three.js updates. Lists breaking changes from r125 onwards and current import paths. CX Codex +1 ★ 4,719repo stars audio-spatial The audio-spatial rule for Claude Code provides Three.js 3D audio patterns for source positioning, distance falloff, and response to user interaction. CX Codex +1 ★ 4,719repo stars debug-devtools The debug-devtools rule guides an agent through adding diagnostics for Three.js performance, scene parameters, and WebGL context loss. Use it when tracking down a rendering bottleneck or inspecting a scene. CX Codex +1 ★ 4,719repo stars tsl-compute-shaders tsl-compute-shaders guides the agent in writing WebGPU compute shaders with Three.js TSL for GPGPU tasks like particle systems and physics. CX Codex +1 ★ 4,719repo stars animation-system animation-system — a practical guide to Three.js animation, from playing and blending clips to morph targets and bones. Useful when building scenes with animated models. CX Codex +1 ★ 4,719repo stars gltf-loading-optimization gltf-loading-optimization is a Claude Code rule with Three.js snippets and commands for glTF loading, decoder setup, progress reporting, lazy loading and model compression. CX Codex +1 ★ 4,719repo stars physics-integration physics-integration guides Three.js integration with Rapier and Cannon-es: Vite setup, collider primitives, and mesh synchronization patterns. CX Codex +1 ★ 4,719repo stars

Project sponsors

Companies that keep this analytics open