mx_divide
mx_divide
MaterialX‑compatible divide node: returns in1 ÷ in2; when in2 is omitted it divides by 1 (returns in1 as is).
Core Advantages
Aligned naming/behavior with MaterialX for easy graph porting; default denominator of 1 cuts boilerplate and reuses TSL’s div() operation.
Common Uses
Build normalized ratios (e.g., distance / radius).
Scale or modulate a signal (roughness, emissive, masks).
Construct ratios/slopes/intensity mappings in procedural shading.
How to adjust
Tune numerator/denominator to reshape the ratio; avoid division by zero by clamping the denominator: mx_divide( a, max( b, EPSILON ) ).
Code Examples
1
2// Ratio of distance to radius -> 0–1 strength
3const d = distance( positionWorld, objectPosition() );
4const k = mx_divide( d, float( 5.0 ) ).saturate();
5material.emissiveNode = vec3( k );
6
7// Omitting the second argument: divide by 1 (pass‑through)
8const passthrough = mx_divide( roughness );
9