#version 150 //OVE shader_name: Circle Crop //OVE shader_description: by fkuteken (License: MIT) //OVE name: Background color //OVE type: COLOR //OVE default: RGBA(0.1, 0.1, 0.2, 1) //OVE description: uniform vec4 bgcolor; // = vec4(0.0, 0.0, 0.0, 1.0) //OVE name: Aspect ratio //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.1 //OVE max: 10.0 //OVE default: 1.0 //OVE description: uniform float aspect_ratio; //OVE name: Smoothness //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE max: 1.0 //OVE default: 0.1 //OVE description: uniform float smoothness; //OVE end #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; uniform vec2 resolution_in; /* animated from 0 to 1 */ uniform float ove_tprog_all; in vec2 ove_texcoord; out vec4 frag_color; vec2 ratio2 = vec2(1.0, resolution_in.y/ resolution_in.x); 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; } } vec2 fix_as( vec2 point) { return vec2( point.x*aspect_ratio*resolution_in.x/resolution_in.y, point.y); } vec4 transition (vec2 uv, float progress) { float dist = length((vec2(uv) - 0.5) * ratio2); float s = pow(2.0 * abs(progress - 0.5), 3.0); return mix( progress < 0.5 ? getFromColor(uv) : getToColor(uv), bgcolor, smoothstep(s-smoothness, s+smoothness , dist) ); } void main(void) { frag_color = transition( ove_texcoord.xy, TransformCurve(1.0 - ove_tprog_all)); }