materialReference
Creates a node that reads a material property and exposes it to the TSL graph using the provided uniform type. If no material is passed, it targets the current object's material.
Core Advantages
Reuses existing material properties as node inputs without adding extra uniforms. One controller material can drive many materials across objects.
Common Uses
Drive other inputs with a property, e.g., use roughness to modulate metalness or emissive strength
Synchronize parameters across many materials by referencing a controller material
Expose standard material properties (color, opacity, envMapIntensity) as composable node inputs
Visualize a property at runtime for debugging
How to adjust
name: the material property key, e.g., 'roughness', 'metalness', 'opacity', 'envMapIntensity'; type: the uniform type that matches the value, such as 'float', 'color', 'vec2', 'vec3', 'vec4'; material: optional Material to lock the reference to. Omit to use the current object's material. Update the referenced JS property at runtime to animate. If you toggle features that change shader defines (e.g., enabling/disabling a map), you may need to set needsUpdate = true on the target material.
Code Examples
1// React (R3F): read roughness from this material to drive metalness
2<mesh>
3 <sphereGeometry args={[0.4, 128, 128]} />
4 <meshStandardNodeMaterial
5 roughness={0.6}
6 metalnessNode={ materialReference('roughness', 'float') }
7 />
8</mesh>
9
10// JS: drive this material's roughness from another material (controllerMat assumed)
11material.roughnessNode = materialReference('roughness', 'float', controllerMat);