Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PerryRylance/cd808293ee30f682b8d4291d9c1fa19f to your computer and use it in GitHub Desktop.
Save PerryRylance/cd808293ee30f682b8d4291d9c1fa19f to your computer and use it in GitHub Desktop.
Post-processing for polar coordinates / planet effect
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
vec2 originalUv = uv;
uv -= 0.5;
vec2 n = normalize(uv);
float a = atan(-uv.y, uv.x) + 3.1415926 / 2.0;
float r = pow(length(uv), 1.0 / sqrt(3.1415926));
float y = r;
float x = fract((1.0 + a / 3.1415926) / 2.0);
vec2 polarUv = vec2(x, y);
float i = iTime;
uv = mix(originalUv, polarUv, fract(iTime));
// Time varying pixel color
vec4 col = texture(iChannel0, uv);
// Output to screen
// fragColor = vec4(r, a, 0.0, 1.0);
fragColor = col;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment