Polar coordinates
In a polar coordinate system, each point is determined by a distance from a reference point (called the pole and specified by center
) and an angle from a reference direction. Long story short, it’s great for making stuff circular.
vec2 polar_coordinates(vec2 uv, vec2 center, float zoom, float repeat)
{
vec2 dir = uv - center;
float radius = length(dir) * 2.0;
float angle = atan(dir.y, dir.x) * 1.0/(3.1416 * 2.0);
return mod(vec2(radius * zoom, angle * repeat), 1.0);
}
void fragment(){
vec2 polar_uv = polar_coordinates(UV.xy, vec2(0.5), 0.3, 1.0);
COLOR = texture(TEXTURE, polar_uv);
}