atan
A math node that wraps the GLSL `atan(y, x)` function. It takes a point's Y and X coordinates and returns its precise angle relative to the origin (in radians, ranging from -π to π), serving as the core of Cartesian to Polar coordinate conversion.
Core Advantages
Provides the standard, robust method for converting a 2D vector into an unambiguous, full-range (360°) angle. It automatically handles all quadrant and divide-by-zero issues, making it an essential and reliable cornerstone for any radial, rotational, or vortex-like procedural effect.
Common Uses
Converting standard square UVs into polar coordinates to generate radial texture effects like radar sweeps or tree rings.
Creating 360° radial gradients, color compasses, or gauge backgrounds by mapping the angle to a color.
Implementing procedural 'gaze' effects by calculating an angle to dynamically rotate a character's pupil texture.
Creating distorted vortex or spiral patterns by modifying the angle based on its corresponding radius.
How to adjust
This node itself is not configurable. Adjustments are made by changing the input 2D vector (x, y). For example, stretching or squashing the input UV coordinates will change the resulting radial pattern from a circle to an ellipse.
Code Examples
1 // Center the UV coordinates around (0,0)
2 const centeredUV = uv().sub( 0.5 );
3
4 // Calculate the angle for each pixel and map it from [-PI, PI] to [0, 1]
5 const angle = atan( centeredUV.y, centeredUV.x );
6 const angleFactor = angle.div( Math.PI * 2 ).add( 0.5 );
7
8 // Use this factor as a color to generate a 360° radial gradient
9 material.color = vec3( angleFactor );