mx_frame
MaterialX‑compatible alias that returns the current render frame index (unsigned integer, uint); functionally identical to frameId and ideal for discrete, per‑frame logic.
Core Advantages
Enables straightforward MaterialX porting and provides a discrete, drift‑free counter independent of wall‑clock time—perfect for parity toggles, stepped animation, dithering, or TAA patterns.
Common Uses
TAA/jitter toggling: switch sampling patterns by frame parity.
Stop‑motion/stepped updates: advance state every N frames.
Per‑frame noise seed: create flicker/film grain or blue‑noise dithering.
Flipbook atlas: use mod(mx_frame(), numFrames) to select sub‑frames.
How to adjust
Read‑only and increments by 1 per rendered frame. Change the modulo base (e.g., 8→16) to alter the cycle length; combine with comparisons or integer division to build stepped animations. For continuous time, use time or deltaTime.
Code Examples
1
2// Toggle between two colors every 8 frames (first 4 = A, next 4 = B)
3const phase = mod( mx_frame(), uint(8) );
4const isFirstHalf = phase.lessThan( uint(4) );
5
6material.colorNode = cond(
7 isFirstHalf,
8 color( 0x00ffaa ),
9 color( 0x2244aa )
10);
11