On this page
Polar UVs
Most UVs are Cartesian, they think in right angles, so patterns built on them are grids and stripes. Polar coordinates change the question from “which row and column” to “how far, and at what angle”, and the moment you answer in radius and angle, your patterns become rings, spokes, spirals, and radial ripples, all from the same two numbers.
float2 p = uv - float2(0.5, 0.5);
float r = length(p) * 2.0; // 0 at center, 1 at edge
float a = atan(p.y, p.x); // -PI..PI around the center
float2 polar = float2(r, a / PI + 0.5);
half4 tex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, polar);
From a square to a disk¶
A plain UV is a point in a square. To make it a point in a disk, you subtract the center to move the origin to the middle, and then you describe the same point in two new terms. The radius is the distance from the center, length(p), and the angle is the direction you are facing from the center, atan(y, x). That is the entire conversion, two lines, and every radial effect in the shader world is some function of those two.
// The conversion, step by step:
float2 p = uv - 0.5; // center the square
float r = length(p) * 2.0; // 0..1 across the disk
float a = atan(p.y, p.x); // the direction, in radians
The angle is the interesting one. atan returns radians from minus pi to pi, and because a full circle is 2 pi, you will usually normalize it to 0..1 with a / (2.0 * PI) + 0.5 or use it raw with trigonometry. The angle wraps: just past pi it jumps to minus pi, the same direction, the left edge of the disk. That wrap is a feature, because a function like sin(a * 8.0) runs eight times around the circle and lands on itself, which is exactly the seamless radial repetition you want.
What falls out of it¶
The pleasant part of polar is how much comes for free. Concentric rings are sin(r * N * PI), a function of radius only. Radial spokes are sin(a * N), a function of angle only. A spiral is the sum, sin(r * N1 * PI + a * N2), and it is the single most recognizable “this is procedural” look in shaders. Radial ripples add time to the radius term, and the ring system from Ripplewaves is exactly this with an animated phase.
When you sample a texture with polar coordinates instead of the raw UV, you warp the texture into the disk: straight lines in the image become circles, and a grid becomes a polar rose. It is the UV equivalent of a lens, and it is one of the cheapest distortion effects there is, because the distortion is in the address, not in the pixels.
One caution, inherited from all position driven UVs: the disk fills the square unevenly. The corners of the square are outside the disk, so you either clip them with the radius, r < 1.0, or let the wrap mode decide what the corners show. The Circle pattern chapter is the reference for the clipping side.
What the shader does¶
The shader cycles through radius rings, angle spokes, spirals, and a polar-warped texture, with ring and spoke counts as properties. The spiral is the standout: turning one frequency up makes the whole thing read as a vortex.
Illustrative schematic: Rings, spokes, spirals: the spiral reads as a vortex.
The polar conversion as the base, with a mode enum that picks which two functions of (r, a) to display.
Shader "DecompiledArt/Textures/Projections/PolarUVs/PolarUVs"
{
Properties
{
[MainColor] _BaseColor("Base Color", Color) = (0.3, 0.6, 1.0, 1)
_Rings("Rings", Range(1, 24)) = 8
_Spokes("Spokes", Range(1, 24)) = 6
[Enum(Rings,0,Spokes,1,Spiral,2,WarpedTexture,3)] _Mode("Mode", Float) = 2
_DetailTex("Texture (for WarpedTexture)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
Pass
{
Name "ForwardOnly"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D(_DetailTex); SAMPLER(sampler_DetailTex);
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
float _Rings;
float _Spokes;
half _Mode;
CBUFFER_END
Varyings Vert(Attributes IN)
{
Varyings OUT;
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
return OUT;
}
half4 Frag(Varyings IN) : SV_Target
{
float2 p = IN.uv - 0.5;
float r = length(p) * 2.0;
float a = atan(p.y, p.x);
half v = 0.0h;
if (_Mode < 0.5h)
v = 0.5h + 0.5h * sin(r * _Rings * PI);
else if (_Mode < 1.5h)
v = 0.5h + 0.5h * sin(a * _Spokes);
else if (_Mode < 2.5h)
v = 0.5h + 0.5h * sin(r * _Rings * PI + a * _Spokes);
else
v = SAMPLE_TEXTURE2D(_DetailTex, sampler_DetailTex, float2(r, a / PI + 0.5)).r;
// Clip the corners of the square, outside the unit disk.
half4 col = half4(v, v, v, 1.0h) * _BaseColor;
return col * saturate(1.0 - r * 0.5) * step(r, 1.0);
}
ENDHLSL
}
}
FallBack Off
}
🔗 Related Chapters¶
Circle • Ripplewaves • Bulge UVs
Related functions: Length • Sine/Cosine
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.