Shader Story
August 1, 2025 ยท View on GitHub
Patterns & Shapes: Whirl
This pattern uses polar coordinates, angle, and radius combined with frac() and step() to create a swirling, tileable whirl effect. Great for dynamic backgrounds, stylized distortions, or rotational transitions.
half2 uvs_centered = uv - 0.5;
half angle = atan2(uvs_centered.y, uvs_centered.x);
half radius = length(uvs_centered);
half whirl_coords = _Whirl_Density * angle + _Whirl_Twist * radius * 6.2831;
half mask_whirl = step(0.5, frac(whirl_coords / 3.14159));
Visual demo
This shader converts UVs into polar coordinates, then modulates the pattern by combining angular and radial components. Using frac() and step() produces a clean, alternating swirl pattern with controllable density and twist.
URP Shader Code
Shader "DecompiledArt/Patterns/Whirl/Whirl"
{
Properties
{
_Tint_01("Tint_01", Color) = (1,1,1,1)
_Tint_02("Tint_02", Color) = (0,0,0,1)
_Whirl_Density("Whirl_Density", Range(1.0, 30.0)) = 10.0
_Whirl_Twist("Whirl_Twist", Range(0.0, 10.0)) = 5.0
}
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline" }
Pass
{
...
half4 frag(Varyings IN) : SV_Target
{
half2 uvs_centered = IN.uvs - 0.5;
half angle = atan2(uvs_centered.y, uvs_centered.x);
half radius = length(uvs_centered);
half whirl_coords = _Whirl_Density * angle + _Whirl_Twist * radius * 6.2831;
half mask_whirl = step(0.5, frac(whirl_coords / 3.14159));
half3 col_output = lerp(_Tint_01.rgb, _Tint_02.rgb, mask_whirl);
return half4(col_output, 1.0);
}
ENDHLSL
}
}
}
URP Shader graph
๐ Related Functions
โค๏ธ Support Shader Story
If this article helped you, consider supporting the project on Patreon - you'll get access to the related source files, reference cheat-sheets, and other exclusive resources:
Your support helps keep this library open, growing, and free for everyone.