mx_rotate2d
A MaterialX‑compatible 2D rotation helper. It coerces the input to vec2 and the angle (degrees) to float, converts degrees to radians, then calls rotate(input, radians).
Core Advantages
Angle‑driven and concise—no manual radian math or matrix building. Works with UV/screenUV/any 2D vector and eases porting MaterialX graphs to TSL.
Common Uses
Rotate UVs around the center to turn textures/normal maps/noise patterns.
Rotate screen‑space patterns or directional effects (e.g., scanlines, motion streaks).
Orient procedural 2D patterns (stripes, checker) to arbitrary angles.
Re‑orient flow maps or direction masks in tangent/planar spaces.
How to adjust
Tune the second argument, amount (degrees). Positive is counter‑clockwise, negative is clockwise (standard Cartesian frame). To rotate about an arbitrary center C use p' = mx_rotate2d(p - C, amount) + C; for UVs, C = vec2(0.5) rotates around the texture center. Drive amount with time (e.g., timerLocal().mul(30)) for continuous rotation.
Code Examples
1// Rotate UVs 45° around the center, then sample a texture
2const uvCentered = uv().sub( 0.5 );
3const uvRotated = mx_rotate2d( uvCentered, 45.0 ).add( 0.5 );
4
5material.colorNode = texture( myTexture, uvRotated );