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.
Check the actual renderer and package peer dependencies first. This example targets Fiber 9.7 / React 19 with @react-three/postprocessing 3.1 and postprocessing 6.39 on WebGL. Do not combine arbitrary newest package versions or silently upgrade a project.
RenderPipeline on r183+; verify that backend separately.gl.render can overwrite or duplicate its output.Mount beneath Canvas. Click the left box to toggle selection. Both boxes are bright, but only the selected object contributes to this bloom pass.
import { useMemo, useRef, useState } from 'react'
import { EffectComposer, Select, Selection, SelectiveBloom, ToneMapping } from '@react-three/postprocessing'
import { ToneMappingMode } from 'postprocessing'
import type { DirectionalLight } from 'three'
export default function Example() {
const light = useRef<DirectionalLight>(null)
const lights = useMemo(() => [light], [])
const [selected, setSelected] = useState(true)
return (
<Selection>
<directionalLight ref={light} position={[0, 3, 5]} intensity={2} />
<Select enabled={selected}>
<mesh name="bloom-selected" position={[-1.2, 0, 0]} onClick={() => setSelected((value) => !value)}>
<boxGeometry args={[0.7, 0.7, 0.7]} />
<meshStandardMaterial color="black" emissive="white" emissiveIntensity={3} />
</mesh>
</Select>
<mesh name="bloom-control" position={[1.2, 0, 0]}>
<boxGeometry args={[0.7, 0.7, 0.7]} />
<meshStandardMaterial color="black" emissive="white" emissiveIntensity={3} />
</mesh>
<EffectComposer multisampling={0}>
<SelectiveBloom lights={lights} luminanceThreshold={0} intensity={2} mipmapBlur />
<ToneMapping mode={ToneMappingMode.ACES_FILMIC} />
</EffectComposer>
</Selection>
)
}
ref.current becoming non-null does not trigger a React render. Do not gate the initial mounting of an effect on a ref assignment alone; use supported refs or callback-ref state where an object is needed reactively.<EffectComposer enableNormalPass>; enable extra buffers only for effects that require them. Check the installed effect's source/types if docs and behavior disagree.target is a world position (vector/tuple), not a mesh ref. focusDistance={0} is not a universal autofocus switch; use a supported target or Autofocus helper.mainImage/mainUv, uniforms, input-buffer, and effect-attribute contracts; a UV-changing effect needs the appropriate convolution declaration.dispose={null} without an owner, or dispose a shared effect from one consumer.Render the full pipeline, toggle effects/selection, resize, and unmount/remount under Strict Mode. Confirm selected-only behavior and final color output; TypeScript cannot prove either.
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer