Skip to main content
rule CX Codex

postprocessing-optimization — Claude Code rule: setup and usage

postprocessing-optimization is a rule for Three.js and React Three Fiber that helps optimize post-processing by combining shader passes and tuning render settings.

MIT ★ 4,719 updated 2026-10-24

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

What postprocessing-optimization does

The rule establishes standards for real-time graphics pipelines. It guides agents to switch from the default Three.js composer to pmndrs/postprocessing, turn off hardware multisampling when not needed, and disable stencil and depth buffers directly on WebGLRenderer.

It enforces batching compatible post-processing stages into a single EffectPass rather than chaining multiple passes. Final stages receive tone mapping and anti-aliasing like SMAAEffect or FXAA, while heavy glows switch to SelectiveBloomEffect. Native TSL node passes handle WebGPU projects.

Keeping antialias: true on WebGLRenderer wastes GPU cycles when a post-processing anti-aliasing pass already runs at the end.

What it helps with

  • bundle multiple post-processing effects into a single EffectPass
  • disable redundant depth and stencil buffers in WebGLRenderer
  • restrict bloom to chosen objects using SelectiveBloomEffect
  • configure native TSL post-processing for WebGPU

Example prompts for the agent

  • Review my Three.js post-processing pipeline and merge compatible passes
  • Set up selective bloom for the highlighted mesh and place SMAA at the end
  • Configure WebGLRenderer settings and disable unneeded multisampling

How to install postprocessing-optimization

Manually: put the files in place

.claude/rules/postprocessing-optimization.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 postprocessing-optimization

How do I install postprocessing-optimization in Claude Code?

Save the rule file to .claude/rules/postprocessing-optimization.md.

What does postprocessing-optimization do?

It directs the coding agent to apply proven performance tweaks for Three.js effects passes, renderer flags, and WebGPU TSL setups.

Why does the rule advise against Three.js default EffectComposer?

It recommends pmndrs/postprocessing because that library combines compatible shaders into fewer draw calls.

Source text

postprocessing-optimization.md · MIT
# Post-Processing Optimization

> Source: [100 Three.js Tips - Utsubo](https://www.utsubo.com/blog/threejs-best-practices-100-tips)

Post-processing can significantly impact performance. Optimize carefully.

## Use pmndrs/postprocessing (WebGL)

The pmndrs library is more performant than Three.js default EffectComposer:

```javascript
import { EffectComposer, Bloom, Vignette, EffectPass, RenderPass } from 'postprocessing';

const composer = new EffectComposer(renderer);
composer.addPass(new RenderPass(scene, camera));
composer.addPass(new EffectPass(camera, new Bloom(), new Vignette()));

// In render loop
composer.render();
```

## Configure Renderer for Post-Processing

```javascript
const renderer = new THREE.WebGLRenderer({
  powerPreference: 'high-performance',
  antialias: false,      // AA handled by post-processing
  stencil: false,        // Disable if not needed
  depth: false           // Disable if not needed
});
```

## Disable Multisampling When Not Needed

```jsx
// React Three Fiber
<EffectComposer multisampling={0}>
  <Bloom />
</EffectComposer>
```

## Apply Tone Mapping at Pipeline End

```javascript
renderer.toneMapping = THREE.NoToneMapping;

// Add ToneMappingEffect as the LAST effect
composer.addPass(new EffectPass(camera, new ToneMappingEffect()));
```

## Add Antialiasing at the End

```javascript
import { SMAAEffect } from 'postprocessing';

// SMAA as the final pass
composer.addPass(new EffectPass(camera, new SMAAEffect()));
```

## Merge Compatible Effects

Reduce passes by combining effects:

```javascript
// BAD: Multiple passes
composer.addPass(new EffectPass(camera, new Bloom()));
composer.addPass(new EffectPass(camera, new Vignette()));
composer.addPass(new EffectPass(camera, new ChromaticAberration()));

// GOOD: Single pass with multiple effects
composer.addPass(new EffectPass(
  camera,
  new Bloom(),
  new Vignette(),
  new ChromaticAberration()
));
```

## Resolution Scaling

Half resolution can double frame rate:

```javascript
// Render at half resolution
composer.setSize(window.innerWidth / 2, window.innerHeight / 2);
```

## Selective Bloom

Only bloom objects that need it:

```javascript
import { SelectiveBloomEffect } from 'postprocessing';

const bloom = new SelectiveBloomEffect(scene, camera, {
  luminanceThreshold: 0.9,
  luminanceSmoothing: 0.3
});

// Add objects to bloom selection
bloom.selection.add(glowingObject);
```

## Bloom Parameter Tuning

| Parameter | Range | Description |
|-----------|-------|-------------|
| intensity | 0.5-2.0 | Overall strength |
| luminanceThreshold | 0.8-1.0 | Minimum brightness to bloom |
| radius | 0.5-1.0 | Spread size |

## WebGPU Native Post-Processing

For WebGPU, use Three.js native TSL-based post-processing:

```javascript
import { pass, bloom, fxaa } from 'three/tsl';

const postProcessing = new THREE.PostProcessing(renderer);
const scenePass = pass(scene, camera);

postProcessing.outputNode = scenePass
  .pipe(bloom({ threshold: 0.8, intensity: 1.0 }))
  .pipe(fxaa());

// In render loop
postProcessing.render();
```

## Performance Checklist

- [ ] Use pmndrs/postprocessing for WebGL
- [ ] Disable renderer AA, stencil, depth when using post-processing
- [ ] Merge compatible effects into single pass
- [ ] Add AA (SMAA/FXAA) as final effect
- [ ] Apply tone mapping at end
- [ ] Consider resolution scaling for mobile
- [ ] Use selective bloom instead of full-screen
- [ ] Disable multisampling when not needed
- [ ] Use TSL post-processing for WebGPU

© zebbern · MIT · zebbern/claude-code-guide

Similar IDE rules

All IDE rules for Frontend and UI →

From the same set86

The whole set →
geometry-instanced-mesh geometry-instanced-mesh guides AI agents to use THREE.InstancedMesh instead of separate meshes for repeating 3D objects. CX Codex +1 ★ 4,719repo stars webgpu-renderer The webgpu-renderer rule guides Three.js WebGPU setup with a WebGL 2 fallback. Use it when a 3D scene needs compute work, GPU particles, or indirect rendering. CX Codex +1 ★ 4,719repo stars tsl-material-slots tsl-material-slots is a Claude Code rule with a reference to Three.js TSL material slots. It helps write node-based shader logic without mistyping slot names or property types. CX Codex +1 ★ 4,719repo stars core-web-vitals core-web-vitals is a Claude Code rule for loading Three.js models and textures without letting heavy 3D delay first paint or degrade LCP, FID and CLS. CX Codex +1 ★ 4,719repo stars timeline-builder timeline-builder is a Claude Code skill that turns JSON event data into interactive HTML timelines with vertical, horizontal, or dual-side layouts. It covers project milestones, release histories, and resumes. CX Codex +1 ★ 4,719repo stars loading-suspense loading-suspense — a rule that keeps async React Three Fiber components inside Suspense, so a model still downloading doesn't leave the canvas blank. CX Codex +1 ★ 4,719repo stars 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

Project sponsors

Companies that keep this analytics open