Skip to content

Instantly share code, notes, and snippets.

@CharStiles
Created April 7, 2021 00:27
Show Gist options
  • Save CharStiles/2cee0764c3bf15c93ca4df058312e842 to your computer and use it in GitHub Desktop.
Save CharStiles/2cee0764c3bf15c93ca4df058312e842 to your computer and use it in GitHub Desktop.
float smoothMod(float x, float y, float e){
float top = cos(PI * (x/y)) * sin(PI * (x/y));
float bot = pow(sin(PI * (x/y)),2.)+ pow(e, sin(time));
float at = atan(top/bot);
return y * (1./2.) - (1./PI) * at ;
}
void main () {
vec2 masterUV = uvN();
vec2 pos = masterUV;
pos.x *= resolution.x/resolution.y;
float wavy = sin(pos.y*40.)*(0.06*clamp(pos.y-0.2,0.,1.)) ;
vec2 swirly = vec2(smoothMod(pos.x*10.,1.,0.2), smoothMod(pos.y*10.,1.,0.2));
wavy+= atan(swirly.x,swirly.y)*0.01;
vec2 newPos = pos + vec2(wavy,0.5);
//newPos.y = mod(newPos.y - time/20., 1.);
vec4 col = texture2D(channel0, newPos);
pos *= resolution.y/ resolution;
vec4 bb = texture2D(backbuffer, pos - vec2(0,0.01) - (wavy*0.1));
gl_FragColor = mix(col, bb, clamp(newPos.y -0.2,0.,1.));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment