What problem does it solve?
Developers often struggle to create bespoke visual effects in Three.js because writing GLSL shaders, managing uniforms, and integrating them with existing materials can be complex and error‑prone.
Core Features & Use Cases
- ShaderMaterial & RawShaderMaterial: Choose between high‑level convenience or low‑level full control for custom vertex and fragment programs.
- Uniform Management: Define numbers, vectors, colors, matrices, textures, and arrays; update them efficiently from JavaScript.
- Varyings & Varyings: Pass data from vertex to fragment shaders for effects like normal‑based coloring or UV mapping.
- Common Shader Patterns: Ready‑to‑use snippets for texture sampling, vertex displacement, Fresnel, noise, gradients, rim lighting, and dissolve effects.
- Extending Built‑in Materials: Use
onBeforeCompile to inject custom code into standard materials such as MeshStandardMaterial.
- Performance Tips: Guidance on minimizing uniforms, avoiding conditionals, pre‑calculating values, and limiting overdraw.
Quick Start
Use the threejs-shaders skill to add a custom wave displacement shader to a mesh in your Three.js scene.