#version 150 //OVE shader_name: Directional Scaled //OVE shader_description: by Thibaut Foussard (License: MIT) //OVE name: Direction //OVE type: POINT //OVE shape: SQUARE //OVE default: (0.1, 0.9) //OVE color: RGBA(1,0,1,1) //OVE description: uniform vec2 direction; //OVE name: Scale //OVE type: FLOAT //OVE min: 0.1 //OVE max: 10.0 //OVE default: 0.7 //OVE description: uniform float scale; //OVE end #define PI acos(-1.0) #define LINEAR_CURVE 0 #define EXPONENTIAL_CURVE 1 #define LOGARITHMIC_CURVE 2 uniform sampler2D out_block_in; uniform sampler2D in_block_in; uniform bool out_block_in_enabled; uniform bool in_block_in_enabled; uniform int curve_in; /* animated from 0 to 1 */ uniform float ove_tprog_all; in vec2 ove_texcoord; out vec4 frag_color; float progress; vec4 getFromColor( vec2 p) { return texture( in_block_in, p); } vec4 getToColor( vec2 p) { return texture( out_block_in, p); } float TransformCurve(float linear) { if (curve_in == EXPONENTIAL_CURVE) { return linear * linear; } else if (curve_in == LOGARITHMIC_CURVE) { return sqrt(linear); } else { return linear; } } float parabola(float x) { float y = pow(sin(x * PI), 1.); return y; } vec4 transition (vec2 uv) { float easedProgress = pow(sin(progress * PI / 2.), 3.); vec2 p = uv + easedProgress * sign(direction - vec2(0.5)); vec2 f = fract(p); float s = 1. - (1. - (1. / scale)) * parabola(progress); f = (f - 0.5) * s + 0.5; float mixer = step(0.0, p.y) * step(p.y, 1.0) * step(0.0, p.x) * step(p.x, 1.0); vec4 col = mix(getToColor(f), getFromColor(f), mixer); float border = step(0., f.x) * step(0., (1. - f.x)) * step(0., f.y) * step(0., 1. - f.y); col *= border; return col; } void main(void) { progress = TransformCurve(1.0 - ove_tprog_all); frag_color = transition( ove_texcoord.xy); }