// RotateScaleVanish — generated from https://github.com/gl-transitions/gl-transitions/blob/master/transitions/RotateScaleVanish.glsl
// Author: Mark Craig
// License: MIT
// Description: The outgoing image spins and shrinks away over the incoming one

uniform shader _from;
uniform shader _to;
uniform float2 _resolution;
uniform float progress;
uniform float ratio;

vec4 getFromColor(vec2 uv) { return vec4(unpremul(_from.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }
vec4 getToColor(vec2 uv) { return vec4(unpremul(_to.eval(vec2(uv.x, 1.0 - uv.y) * _resolution))); }

uniform int FadeInSecond; 

uniform int ReverseEffect; 

uniform int ReverseRotation; 

vec4 transition(vec2 uv)
{
vec2 iResolution = vec2(ratio, 1.0);
float t = (ReverseEffect != 0) ? 1.0 - progress : progress;
float theta = (ReverseRotation != 0) ? 6.283185307179586476925286766559 * t : -6.283185307179586476925286766559 * t;
float c1 = cos(theta);
float s1 = sin(theta);
float rad = max(0.00001, 1.0 - t);
float xc1 = (uv.x - 0.5) * iResolution.x;
float yc1 = (uv.y - 0.5) * iResolution.y;
float xc2 = (xc1 * c1 - yc1 * s1) / rad;
float yc2 = (xc1 * s1 + yc1 * c1) / rad;
vec2 uv2 = vec2(xc2 + iResolution.x / 2.0, yc2 + iResolution.y / 2.0);
vec4 col3;
vec4 ColorTo = (ReverseEffect != 0) ? getFromColor(uv) : getToColor(uv);
if ((uv2.x >= 0.0) && (uv2.x <= iResolution.x) && (uv2.y >= 0.0) && (uv2.y <= iResolution.y))
	{
	uv2 /= iResolution;
	col3 = (ReverseEffect != 0) ? getToColor(uv2) : getFromColor(uv2);
	}
else { col3 = (FadeInSecond != 0) ? vec4(0.0, 0.0, 0.0, 1.0) : ColorTo; }
return((1.0 - t) * col3 + t * ColorTo); 
}

half4 main(float2 _coord) {
  vec2 _uv = _coord / _resolution;
  vec4 _c = clamp(transition(vec2(_uv.x, 1.0 - _uv.y)), 0.0, 1.0);
  return half4(_c.rgb * _c.a, _c.a);
}
