Skip to content

Instantly share code, notes, and snippets.

@kofigumbs
Created October 16, 2019 20:37
Show Gist options
  • Save kofigumbs/98e816b836f7d39ff3491e54e409f48c to your computer and use it in GitHub Desktop.
Save kofigumbs/98e816b836f7d39ff3491e54e409f48c to your computer and use it in GitHub Desktop.
#version 150
uniform float time;
uniform vec2 resolution;
uniform sampler2D bitmoji;
in VertexData
{
vec4 v_position;
vec3 v_normal;
vec2 v_texcoord;
} inData;
out vec4 fragColor;
vec2 dance(float time, vec2 uv, vec2 point, vec2 offset) {
int animSteps = 60;
float animDist = 0.003;
vec2 diff = abs(uv - point);
vec2 value = vec2(0.);
for(int i = 0; i < animSteps; i++) {
if (diff.y < i*animDist) {
value.x += offset.x*time;
}
if (diff.x < i*animDist) {
value.y += offset.y*time;
}
}
return value;
}
void main(void)
{
vec2 uv = inData.v_texcoord;
vec2 img = vec2(uv.x, 1-uv.y);
img += dance(sin(time*4)/4, uv, vec2(0.5, 0.7), vec2(0., 0.0002));
img += dance(sin(time*8), uv, vec2(0.5, 0.3), vec2(0.0003, 0.));
img += dance(cos(time*16), uv, vec2(0.5, 0.), vec2(0., 0.0001));
fragColor = texture(bitmoji, img);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment