Created
March 14, 2016 07:56
-
-
Save rpetrano/d83f5ca07f3dca041f9b to your computer and use it in GitHub Desktop.
Simple spiral GLSL shader
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) | |
{ | |
vec2 mpos = iMouse.xy / iResolution.xy; | |
vec2 pos = fragCoord.xy / iResolution.xy; | |
const float R = 1.5; | |
vec2 kpos = pos - mpos; | |
float r = length (kpos); | |
float phi = atan (kpos.y, kpos.x); | |
phi += 100.0 * r/R + 10.0*iGlobalTime; | |
// phi += 1.0 * R/r + 10.0*iGlobalTime; | |
kpos = r * vec2 (cos (phi), sin (phi)); | |
if (r <= R) { | |
// vec2 tex = mpos + kpos / (1.0); | |
vec2 tex = mpos + kpos / (2.0 * R); | |
fragColor = texture2D (iChannel0, tex); | |
} else { | |
fragColor = texture2D (iChannel0, pos); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment