Polar Gradient (Angle)
Horizontal gradients use vUv.x, vertical use vUv.y, diagonal uses their average. There's another direction: angle — use atan to convert coordinates into a 0–1 rotation factor.
atan gives angle
Center the coordinates first, then compute angle:
atan(y, x) returns the direction angle of the current pixel relative to center, ranging from -π to π (approximately -3.14 to 3.14).
Map to 0–1
Adding π shifts the range from -π~π to 0~2π. Dividing by 2π normalizes to 0–1.
Result: going counterclockwise around the center, color sweeps from colorA to colorB.
Exercise
The exercise starts with t = 0.0 (solid colorA). Compute the angle a, then map it to 0–1 to get t, producing a rotating color sweep.
Answer Breakdown
atan(y, x) is the two-argument arctangent that returns the direction angle for a given coordinate. 3.14159265 is π and 6.2831853 is 2π.
You'll notice a seam on the right side (3 o'clock position) where atan jumps from π back to -π. This is normal for polar gradients — the seam is where the 0 and 1 endpoints meet.