A production-grade Toon Shader for Three.js.
This package provides a robust implementation of Cel Shading (via Gradient Maps) and Edge Detection (via Post-Processing). Unlike the common "Inverted Hull" technique, this uses Depth and Normal buffers to detect edges, ensuring perfect outlines on complex geometry, internal edges, and intersecting objects without duplicating geometry.
- 🎨 Surface Cel Shading: Helper to apply
MeshToonMaterialwith quantized gradient maps. - 🖊️ Advanced Outlines: Post-processing shader that detects edges using:
- Depth Discontinuity: Detects objects in front of others.
- Normal Discontinuity: Detects sharp edges within a single object (e.g., corners of a cube).
- 📷 Distance Attenuation: Lines fade out or thin as objects move further away to reduce noise.
- 🧩 Composable: Framework agnostic. Works with Vanilla JS, Vue (Nuxt), React (R3F), etc.
This project relies on three as a peer dependency.
npm install three
# or
yarn add three- Clone the repository.
- Install dependencies:
npm install