Skip to content

Instantly share code, notes, and snippets.

@corporateshark
Forked from glslioadmin/TEMPLATE.glsl
Created May 21, 2014 14:43
Show Gist options
  • Save corporateshark/cacfedb8cca0f5ce3f7c to your computer and use it in GitHub Desktop.
Save corporateshark/cacfedb8cca0f5ce3f7c to your computer and use it in GitHub Desktop.
GLSL.io Transition (v1)
#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D from, to;
uniform float progress;
uniform vec2 resolution;
/*
(C) Sergey Kosarevsky, 2014
Available under the terms of MIT license
http://www.linderdaum.com
*/
void main(void)
{
float Radius = 1.0;
float T = progress;
vec2 UV = gl_FragCoord.xy / resolution.xy;
UV -= vec2( 0.5, 0.5 );
float Dist = length(UV);
if ( Dist < Radius )
{
float Percent = (Radius - Dist) / Radius;
float A = ( T <= 0.5 ) ? mix( 0.0, 1.0, T/0.5 ) : mix( 1.0, 0.0, (T-0.5)/0.5 );
float Theta = Percent * Percent * A * 8.0 * 3.14159;
float S = sin( Theta );
float C = cos( Theta );
UV = vec2( dot(UV, vec2(C, -S)), dot(UV, vec2(S, C)) );
}
UV += vec2( 0.5, 0.5 );
vec4 C0 = texture2D( from, UV );
vec4 C1 = texture2D( to, UV );
gl_FragColor = mix( C0, C1, T );
}
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