Skip to content

Instantly share code, notes, and snippets.

@supahfunk
Created April 24, 2022 08:37
Show Gist options
  • Save supahfunk/46ad870a6cad032e9afd5fbc9d5d3a3b to your computer and use it in GitHub Desktop.
Save supahfunk/46ad870a6cad032e9afd5fbc9d5d3a3b to your computer and use it in GitHub Desktop.
Twirl glsl
uniform sampler2D textureMap; //image
uniform float amount; //amount of twirl
void main() {
vec2 uv = gl_TexCoord[0].st-0.5;
float angle = atan2(uv.y,uv.x);
float radius = length(uv);
angle+= radius*amount;
vec2 shifted = radius*vec2(cos(angle), sin(angle));
gl_FragColor = texture(textureMap, (shifted+0.5));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment