Skip to content

marselo-4/TotAuto / .claude/skills/r3f-shaders

r3f-shaders

Verified

Implement custom GLSL or TSL materials in React Three Fiber, including uniforms and vertex deformation. Use for shader code and shader debugging, rather than ordinary PBR settings or composer effects.

FileKindSize
SKILL.mdskill md5.4 KB
references/webgpu.mdmarkdown1.6 KB

references/webgpu.md

View on GitHub
# TSL materials on WebGPU

Use with an already initialized WebGPURenderer. This example targets Fiber 9.7 / Three.js r185, not Fiber 10 alpha.

```tsx
import { useMemo } from 'react'
import { extend } from '@react-three/fiber'
import { MeshBasicNodeMaterial } from 'three/webgpu'
import { color, mix, sin, time, uv } from 'three/tsl'

const BasicNode = extend(MeshBasicNodeMaterial)

export default function NodeGradient() {
  const colorNode = useMemo(() => {
    const factor = sin(uv().y.mul(6).add(time)).mul(0.5).add(0.5)
    return mix(color('navy'), color('coral'), factor)
  }, [])
  return (
    <mesh>
      <planeGeometry args={[3, 3]} />
      <BasicNode colorNode={colorNode} />
    </mesh>
  )
}
```

- Build stable node graphs outside per-frame work. Update uniform node values rather than recreating the graph each frame.
- Node materials handle their own output pipeline; do not paste GLSL output chunks into TSL.
- Use `positionGeometry` for pre-transformed vertices and understand `positionLocal` semantics before combining deformation with skinning in r185.
- Use the installed Three.js `RenderPipeline` and node passes for postprocessing. Older tutorials using `PostProcessing`, renamed helpers, or Fiber alpha hooks need version checks.
- Type-checking does not prove GPU compatibility. Render on the requested backend; verify WebGPU separately from its WebGL2 fallback.

Sources: [TSL guide](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language), [MeshBasicNodeMaterial](https://threejs.org/docs/#MeshBasicNodeMaterial), [migration guide](https://github.com/mrdoob/three.js/wiki/Migration-Guide).
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall