precision highp float; varying vec2 textureCoordinate; uniform sampler2D from; uniform sampler2D to; uniform float progress; vec4 getFromColor(vec2 uv) { return texture2D(from,uv); } vec4 getToColor(vec2 uv){ return texture2D(to,uv); } vec4 transition(vec2 UV) { float Radius = 1.0; float T = progress; 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 = getFromColor(UV); vec4 C1 = getToColor(UV); return mix( C0, C1, T ); } void main(){ gl_FragColor = transition(textureCoordinate); }