Skip to content

Instantly share code, notes, and snippets.

@clauswitt
Forked from glslioadmin/TEMPLATE.glsl
Created January 15, 2016 07:31
Show Gist options
  • Save clauswitt/95340a33be115c37597f to your computer and use it in GitHub Desktop.
Save clauswitt/95340a33be115c37597f to your computer and use it in GitHub Desktop.
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
// General parameters
uniform sampler2D from;
uniform sampler2D to;
uniform float progress;
uniform vec2 resolution;
uniform float colorSeparation;
float progressY (float y) {
return 0.5 + (y-0.5) / (1.0-progress);
}
float progressX (float x) {
return 0.5 + (x-0.5) / (1.0-progress);
}
void main() {
vec2 p = gl_FragCoord.xy / resolution.xy;
float y = progressY(p.y);
float x = progressX(p.x);
// if (y < 0.0 || y > 1.0 || x < 0.0 || x > 1.0) {
if (y < 0.0 || y > 1.0 ) {
gl_FragColor = texture2D(to, p);
}
else {
vec2 fp = vec2(p.x, y);
vec3 c = vec3(
texture2D(from, fp - progress*vec2(0.0, colorSeparation)).r,
texture2D(from, fp).g,
texture2D(from, fp + progress*vec2(0.0, colorSeparation)).b
);
gl_FragColor = vec4(c, 1.0);
}
}
{"colorSeparation":0}
GLSL.io Transition License (v1):
The MIT License (MIT)
Copyright (C) 2014 [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment