Extend Three.js standard materials with custom vertex and fragment shaders for both vanilla and React environments.
Custom Shader Material is a Three.js library that allows developers to extend standard Three.js materials with custom vertex and fragment shaders. It solves the problem of wanting custom shader effects while retaining the lighting, roughness, transmission, and other properties of built-in materials like MeshPhysicalMaterial. Instead of creating a ShaderMaterial from scratch, developers can inject GLSL code into existing materials.
Three.js developers and creative coders who need custom shader effects but want to preserve standard material features, especially those working with React Three Fiber or vanilla Three.js projects.
Developers choose Custom Shader Material because it provides a clean, type-safe API for shader injection without losing Three.js' built-in material capabilities, offering a middle ground between standard materials and fully custom shaders.
🧩 Extend Three.js standard materials with your own shaders!
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Maintains base material attributes like roughness, metalness, and transmission while allowing custom shader logic, enabling enhanced visual effects without rebuilding standard features from scratch.
Works seamlessly in both vanilla Three.js and React Three Fiber projects, with dedicated imports and examples for each, providing flexibility across different development environments.
Offers full TypeScript support with inferred prop types based on the baseMaterial prop, ensuring type safety and reducing errors during development.
Allows extending already extended materials, enabling layered shader effects for complex visual setups, as demonstrated in the examples with multiple CSM instances.
When using csm_PositionRaw for full control, instancing must be handled manually by multiplying instanceMatrix in shader code, adding complexity for projects relying on instanced rendering.
Bump mapping was removed in v6.4.0 and requires manual implementation using csm_FragNormal, making it less convenient for standard effects and increasing shader code overhead.
Extending already extended materials can lead to redefinition errors for identifiers like uniforms and varyings, requiring careful scoping and increasing debugging difficulty.
Changing props like baseMaterial or shaders triggers material rebuilds, and improper memoization in React can cause unnecessary re-renders, impacting performance in dynamic applications.