mx_add
mx_add
MaterialX‑aligned add wrapper. Sums in1 and in2; if in2 is omitted it defaults to 0. Works with float, vec2, vec3, vec4, and color while preserving types.
Core Advantages
Zero‑cost compatibility with MaterialX graphs. The default 0 enables bias or pass‑through. Semantics match add(in1, in2) for smooth MX → TSL migration.
Common Uses
Add a bias to scalars or vectors
Brighten colors or accumulate lighting
Scroll or offset UV coordinates
Chain additions to sum multiple terms
How to adjust
Change in2 to control the bias. When in1 is a vector, in2 can be a same‑dimension vector or a scalar for broadcasting. For more than two terms, chain calls like mx_add( a, mx_add( b, c ) ) or use add(a, b, c). Ensure type compatibility.
Code Examples
1// Slightly brighten a texture color
2material.colorNode = mx_add( texture( baseMap, uv() ), vec3( 0.1 ) );
3
4// UV scrolling
5const scrolledUV = mx_add( uv(), vec2( timerLocal().mul( 0.1 ) ) );
6material.colorNode = texture( baseMap, scrolledUV );