NodeMaterial
The base class for all node materials. Wire inputs like colorNode, positionNode, vertexNode, and fragmentNode to override the vertex/fragment stages and build custom shaders. Commonly used as a base, but it can also be instantiated directly to assemble bespoke materials.
Core Advantages
Highly modular and composable. Lets you override vertex position, color, normals, opacity, depth, shadows, MRT, and the final output without hand-writing GLSL.
Common Uses
Extend as the base for other node materials
Procedural vertex displacement or animation via positionNode
Fully custom fragment output via fragmentNode or outputNode
Rapid prototyping of new lighting or NPR looks
Per-object masking, alpha test, or MRT writes
How to adjust
Assign nodes to properties: colorNode for base color, opacityNode for transparency, normalNode for surface detail, positionNode for vertex ops. For full control set vertexNode or fragmentNode. Use maskNode, alphaTestNode, backdropNode/backdropAlphaNode, outputNode, mrtNode, depthNode, receivedShadowNode/castShadowNode, receivedShadowPositionNode/castShadowPositionNode, lightsNode, envNode, and aoNode as needed.
Code Examples
1<mesh>
2 <sphereGeometry />
3 {/* Use NodeMaterial directly: override vertex displacement and fragment color */}
4 <nodeMaterial
5 positionNode={
6 positionLocal.add(
7 normalLocal.mul(
8 sin(time).mul(0.1)
9 )
10 )
11 }
12 fragmentNode={color(0.2, 0.6, 1.0)}
13 />
14</mesh>