Skip to content

Instantly share code, notes, and snippets.

@gre
Forked from gre/TEMPLATE.glsl
Last active January 4, 2016 10:29
Show Gist options
  • Save gre/8608795 to your computer and use it in GitHub Desktop.
Save gre/8608795 to your computer and use it in GitHub Desktop.
#ifdef GL_ES
precision highp float;
#endif
// General parameters
uniform sampler2D from;
uniform sampler2D to;
uniform float progress;
uniform vec2 resolution;
// Custom parameters
uniform float size;
uniform float zoom;
uniform float colorSeparation;
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
float inv = 1. - progress;
vec2 disp = size*vec2(cos(zoom*p.x), sin(zoom*p.y));
vec4 texTo = texture2D(to, p + inv*disp);
vec4 texFrom = vec4(
texture2D(from, p + progress*disp*(1.0 - colorSeparation)).r,
texture2D(from, p + progress*disp).g,
texture2D(from, p + progress*disp*(1.0 + colorSeparation)).b,
1.0);
gl_FragColor = texTo*progress + texFrom*inv;
}
{ "size": 0.04, "zoom": 30.0, "colorSeparation": 0.3 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment