mx_multiply
mx_multiply
MaterialX-style multiply alias. Multiplies the first input by the second; if omitted, the second input defaults to `float(1)` so it passes through.
Core Advantages
MaterialX naming parity with TSL’s type-aware multiplication; the default 1 enables single-input wiring and safe incremental edits.
Common Uses
Modulating textures or colors (component-wise)
Scaling vectors, colors, or scalar signals
Matrix × vector or matrix × matrix transforms
How to adjust
Change the second input to control gain: >1 boosts, 0–1 attenuates, 0 zeros out. Clamp when modulating colors to avoid overflow; ensure compatible dimensions for matrix multiplies (e.g., mat4 × vec4).
Code Examples
1
2// 1) Color modulation: texture × tint
3const tinted = mx_multiply( texture( myTexture, uv() ), vec3( 1.2, 0.9, 0.9 ) );
4material.colorNode = tinted;
5
6// 2) Single input becomes pass-through (in2 defaults to 1)
7const passthrough = mx_multiply( diffuseColor );
8
9// 3) Matrix transform: world matrix × position
10const worldPos = mx_multiply( objectWorldMatrix(), vec4( positionLocal, 1.0 ) );