Skip to content

Instantly share code, notes, and snippets.

@gre
Forked from gre/TEMPLATE.glsl
Created January 24, 2014 23:20
Show Gist options
  • Save gre/8608871 to your computer and use it in GitHub Desktop.
Save gre/8608871 to your computer and use it in GitHub Desktop.
{ "direction": [1, -1], "smoothness": 0.5 }
#ifdef GL_ES
precision highp float;
#endif
// General parameters
uniform sampler2D from;
uniform sampler2D to;
uniform float progress;
uniform vec2 resolution;
uniform vec2 direction;
uniform float smoothness;
const vec2 center = vec2(0.5, 0.5);
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
vec2 v = normalize(direction);
v /= abs(v.x)+abs(v.y);
float d = v.x * center.x + v.y * center.y;
float m = smoothstep(-smoothness, 0.0, v.x * p.x + v.y * p.y - (d-0.5+progress*(1.+smoothness)));
gl_FragColor = mix(texture2D(to, p), texture2D(from, p), m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment