r3f-postprocessing
React Three Fiber post-processing - @react-three/postprocessing, bloom, DOF, screen effects. Use when adding visual effects, color grading, blur, glow, or creating custom screen-space shaders.
What this skill does
# React Three Fiber Post-Processing
## Quick Start
```tsx
import { Canvas } from '@react-three/fiber'
import { EffectComposer, Bloom, Vignette } from '@react-three/postprocessing'
function Scene() {
return (
<Canvas>
<ambientLight />
<mesh>
<boxGeometry />
<meshStandardMaterial color="hotpink" emissive="hotpink" emissiveIntensity={2} />
</mesh>
<EffectComposer>
<Bloom luminanceThreshold={0.5} luminanceSmoothing={0.9} intensity={1.5} />
<Vignette offset={0.5} darkness={0.5} />
</EffectComposer>
</Canvas>
)
}
```
## Installation
```bash
npm install @react-three/postprocessing postprocessing
```
## EffectComposer
The container for all post-processing effects.
```tsx
import { EffectComposer } from '@react-three/postprocessing'
function Scene() {
return (
<Canvas>
{/* Scene content */}
<mesh>...</mesh>
{/* Post-processing - must be inside Canvas, after scene content */}
<EffectComposer
enabled={true} // Toggle all effects
depthBuffer={true} // Enable depth buffer
stencilBuffer={false} // Enable stencil buffer
autoClear={true} // Auto clear before render
multisampling={8} // MSAA samples (0 to disable)
>
{/* Effects go here */}
</EffectComposer>
</Canvas>
)
}
```
## Common Effects
### Bloom (Glow)
```tsx
import { EffectComposer, Bloom } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'
<EffectComposer>
<Bloom
intensity={1.0} // Bloom intensity
luminanceThreshold={0.9} // Brightness threshold
luminanceSmoothing={0.025} // Smoothness of threshold
mipmapBlur={true} // Enable mipmap blur
radius={0.8} // Bloom radius
levels={8} // Mipmap levels
blendFunction={BlendFunction.ADD}
/>
</EffectComposer>
// For objects to glow, use emissive materials
<mesh>
<boxGeometry />
<meshStandardMaterial
color="black"
emissive="#ff00ff"
emissiveIntensity={2}
toneMapped={false} // Important for values > 1
/>
</mesh>
```
### Selective Bloom
```tsx
import { EffectComposer, Bloom, Selection, Select } from '@react-three/postprocessing'
function Scene() {
return (
<Canvas>
<Selection>
<EffectComposer>
<Bloom
luminanceThreshold={0}
intensity={2}
mipmapBlur
/>
</EffectComposer>
{/* This mesh will bloom */}
<Select enabled>
<mesh>
<sphereGeometry />
<meshStandardMaterial emissive="red" emissiveIntensity={2} toneMapped={false} />
</mesh>
</Select>
{/* This mesh will NOT bloom */}
<mesh position={[2, 0, 0]}>
<boxGeometry />
<meshStandardMaterial color="blue" />
</mesh>
</Selection>
</Canvas>
)
}
```
### Depth of Field
```tsx
import { EffectComposer, DepthOfField } from '@react-three/postprocessing'
<EffectComposer>
<DepthOfField
focusDistance={0} // Focus distance (0 = auto)
focalLength={0.02} // Camera focal length
bokehScale={2} // Bokeh size
height={480} // Resolution height
/>
</EffectComposer>
// With target object
import { useRef } from 'react'
function Scene() {
const targetRef = useRef()
return (
<>
<mesh ref={targetRef} position={[0, 0, -5]}>
<boxGeometry />
<meshStandardMaterial color="red" />
</mesh>
<EffectComposer>
<DepthOfField
target={targetRef}
focalLength={0.02}
bokehScale={2}
/>
</EffectComposer>
</>
)
}
```
### Vignette
```tsx
import { EffectComposer, Vignette } from '@react-three/postprocessing'
<EffectComposer>
<Vignette
offset={0.5} // Vignette size
darkness={0.5} // Vignette intensity
eskil={false} // Use Eskil's vignette technique
/>
</EffectComposer>
```
### Noise
```tsx
import { EffectComposer, Noise } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'
<EffectComposer>
<Noise
premultiply // Multiply noise with input
blendFunction={BlendFunction.ADD}
opacity={0.5}
/>
</EffectComposer>
```
### Chromatic Aberration
```tsx
import { EffectComposer, ChromaticAberration } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'
<EffectComposer>
<ChromaticAberration
offset={[0.002, 0.002]} // Color offset
radialModulation={true} // Apply radially
modulationOffset={0.5}
blendFunction={BlendFunction.NORMAL}
/>
</EffectComposer>
```
### SSAO (Screen Space Ambient Occlusion)
```tsx
import { EffectComposer, SSAO } from '@react-three/postprocessing'
import { BlendFunction } from 'postprocessing'
<EffectComposer>
<SSAO
blendFunction={BlendFunction.MULTIPLY}
samples={30} // Amount of samples
radius={5} // Occlusion radius
intensity={30} // Occlusion intensity
luminanceInfluence={0.6}
color="black"
worldDistanceThreshold={100}
worldDistanceFalloff={5}
worldProximityThreshold={0.01}
worldProximityFalloff={0.01}
/>
</EffectComposer>
```
### Outline
```tsx
import { EffectComposer, Outline, Selection, Select } from '@react-three/postprocessing'
function Scene() {
return (
<Canvas>
<Selection>
<EffectComposer autoClear={false}>
<Outline
visibleEdgeColor={0xffffff} // Visible edge color
hiddenEdgeColor={0x22090a} // Hidden edge color
edgeStrength={2.5} // Edge strength
pulseSpeed={0} // Pulse animation speed
blur // Enable blur
xRay // Show behind objects
/>
</EffectComposer>
{/* Outlined object */}
<Select enabled>
<mesh>
<boxGeometry />
<meshStandardMaterial color="orange" />
</mesh>
</Select>
{/* Non-outlined object */}
<mesh position={[2, 0, 0]}>
<sphereGeometry />
<meshStandardMaterial color="blue" />
</mesh>
</Selection>
</Canvas>
)
}
```
### Color Grading
```tsx
import { EffectComposer, BrightnessContrast, HueSaturation } from '@react-three/postprocessing'
<EffectComposer>
<BrightnessContrast
brightness={0} // -1 to 1
contrast={0} // -1 to 1
/>
<HueSaturation
hue={0} // Hue rotation in radians
saturation={0} // -1 to 1
/>
</EffectComposer>
```
### Tone Mapping
```tsx
import { EffectComposer, ToneMapping } from '@react-three/postprocessing'
import { ToneMappingMode } from 'postprocessing'
<EffectComposer>
<ToneMapping
mode={ToneMappingMode.ACES_FILMIC}
// Modes: LINEAR, REINHARD, REINHARD2, OPTIMIZED_CINEON, CINEON, ACES_FILMIC, AGX, NEUTRAL
resolution={256}
whitePoint={4.0}
middleGrey={0.6}
minLuminance={0.01}
averageLuminance={1.0}
adaptationRate={1.0}
/>
</EffectComposer>
```
### Glitch
```tsx
import { EffectComposer, Glitch } from '@react-three/postprocessing'
import { GlitchMode } from 'postprocessing'
<EffectComposer>
<Glitch
delay={[1.5, 3.5]} // Min/max delay between glitches
duration={[0.6, 1.0]} // Min/max duration
strength={[0.3, 1.0]} // Min/max strength
mode={GlitchMode.SPORADIC} // DISABLED, SPORADIC, CONSTANT_MILD, CONSTANT_WILD
active // Enable/disable
ratio={0.85} // Glitch ratio (0 = none, 1 = always)
/>
</EffectComposer>
```
### Pixelation
```tsx
import { EffectComposer, Pixelation } from '@react-three/postprocessing'
<EffectComposer>
<Pixelation
granularity={5} // Pixel size
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.