rotate
A powerful function node for rotating 2D (e.g., UVs) or 3D (e.g., vertex positions) vectors within the shader, abstracting complex rotation math into a simple function call.
Core Advantages
Encapsulates complex rotation matrix and trigonometric calculations, greatly simplifying code and reducing the risk of errors. It enables efficient, dynamic rotations on the GPU and intelligently adapts to the input vector's dimensionality (2D/3D) with a unified interface.
Common Uses
Rotating texture coordinates (UVs) to achieve dynamic texture spinning or orientation correction.
Creating procedural vertex animations, such as an object's self-rotation or swaying, with all calculations performed on the GPU.
Deforming geometry, for instance, creating a twist effect by applying rotation based on vertex attributes.
How to adjust
Control the effect by adjusting the second parameter, `rotationNode`. For example, changing the input from a static value to `time` transitions from a static to a continuous rotation. Modifying the components of the input vector (e.g., from `vec3(0, time, 0)` to `vec3(time, time, 0)`) changes the axis of rotation. Using `sin(time)` instead of `time` transforms a continuous spin into an oscillating or swaying animation.
Code Examples
1// Define an Euler angle rotation around the Y-axis that changes over time
2const rotationAmount = vec3( 0, time, 0 );
3
4// Apply the rotation to the model's local vertex positions
5const rotatedPosition = rotate( positionLocal, rotationAmount );