$npx -y skills add scottstts/Threejs-Awesome-Graphics-Agent-Skills --skill threejs-shadow-systemsImplement stable, scalable directional-shadow systems for Three.js. Use for large procedural worlds, city scenes, terrain, moving cameras, WebGPU/TSL shadow nodes, cascades, cached clipmaps, texel stabilization, update budgets, and targeted invalidation.
| 1 | # Shadow Systems |
| 2 | |
| 3 | Use a single shadow map only when its receiver region is genuinely bounded. For large moving views, make shadow coverage an explicit spatial hierarchy. |
| 4 | |
| 5 | ## Cached clipmap workflow |
| 6 | |
| 7 | 1. Define concentric light-space square levels. |
| 8 | 2. Snap each level center to its own texel grid. |
| 9 | 3. Cross-fade adjacent levels in shader space. |
| 10 | 4. Refresh near levels continuously. |
| 11 | 5. Cache coarse levels and update them under a frame budget. |
| 12 | 6. Invalidate intersecting levels when important casters or streamed terrain change. |
| 13 | 7. Scale normal bias by world-space texel width. |
| 14 | |
| 15 | Read [references/cached-clipmap-shadows.md](references/cached-clipmap-shadows.md) before implementing a large-world directional light. |
| 16 | |
| 17 | Read the |
| 18 | [cached shadow clipmaps](../threejs-procedural-architecture/examples/procedural-financial-tower/shadow-clipmaps.js) |
| 19 | for three light-space square levels, per-level texel snapping, containment |
| 20 | cross-fades, cached coarse updates, scaled bias, and unshadowed outside weight. |
| 21 | |
| 22 | ## Failure conditions |
| 23 | |
| 24 | - projection centers move by fractions of a texel; |
| 25 | - shader containment does not match the map's committed center; |
| 26 | - all cascades refresh every frame without evidence; |
| 27 | - coarse levels freeze moving casters indefinitely; |
| 28 | - depth texture samples occur in divergent fragment control flow; |
| 29 | - the same normal bias is used across radically different texel sizes; |
| 30 | - level boundaries become visible under camera motion. |
| 31 | |
| 32 | ## Routing boundary |
| 33 | |
| 34 | Use this skill for light-space directional shadow maps. Use |
| 35 | `$threejs-screen-space-ambient-occlusion` for view-dependent ambient |
| 36 | visibility; AO is not a replacement for cast shadows. |