Created
November 15, 2021 07:26
-
-
Save PerryRylance/cd808293ee30f682b8d4291d9c1fa19f to your computer and use it in GitHub Desktop.
Post-processing for polar coordinates / planet effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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