r3f-shaders
Installation
SKILL.md
React Three Fiber shaders
Select the shader path
Inspect installed Fiber, Drei, Three.js, and renderer versions first. The example uses Fiber 9 / React 19 and WebGL. Preserve an existing project's versions.
- Use built-in materials when their properties express the effect. For custom WebGL shading, use Drei
shaderMaterialor a native<shaderMaterial>. - WebGPU uses node materials and TSL; GLSL
ShaderMaterialandonBeforeCompileare not portable to it. Read WebGPU and TSL only when that renderer is relevant. - A shader is not automatically lit, shadowed, fogged, instanced, or skinned. Choose the required features before replacing a built-in material.
Animated WebGL material
Mount beneath Canvas. Keep the material class and extend call outside render; the local component avoids global JSX augmentation.
import { useRef } from 'react'
import { extend, useFrame } from '@react-three/fiber'
import { shaderMaterial } from '@react-three/drei'
import { Color } from 'three'