UV Polar Coordinates

This node is already available out of the box Godot. I created a similar node as a tutorial on to defines how it works.

Shader code
shader_type spatial;

uniform vec2 centerCoordinat  = vec2(0.5, 0.5);
uniform float radial_scale : hint_range(0.0, 5.0) = 1.0;
uniform float length_scale : hint_range(0.0, 5.0) = 1.0;
uniform float angle_offset : hint_range(-1.0, 1.0) = 0.0;
uniform float radius_offset : hint_range(-1.0, 1.0) = 0.0;
uniform sampler2D texture_albedo : hint_default_white;

vec2 UVPolarCoordinates(vec2 uv, vec2 center, float radialScale, float lengthScale) {
	vec2 m_delta = uv - center;
	float m_radius = length(m_delta) * 2.0 * radialScale;
	float m_Pi = 6.28318530718;
	float m_angle = atan(m_delta.y, m_delta.x) / (m_Pi * lengthScale);
	return vec2(m_radius, m_angle);
}

void fragment() {
	vec2 polar_uv = UVPolarCoordinates(UV, centerCoordinat, radial_scale, length_scale);
	polar_uv.x += radius_offset;
	polar_uv.y += angle_offset;
	ALBEDO = texture(texture_albedo, polar_uv).xyz;
}
Live Preview
Tags
distortion, polar, PolarCoordinates, PolarUV, uv, Wraping
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from Riko

Related shaders

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments