#version 150 //OVE shader_name: Circle Open //OVE shader_description: by gre (License: MIT) //OVE name: Smoothness //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE max: 10.0 //OVE default: 0.3 //OVE description: uniform float smoothness; //OVE name: Open //OVE type: BOOLEAN //OVE flag: NOT_CONNECTABLE, NOT_KEYFRAMABLE //OVE default: true //OVE description: uniform bool opening; //OVE name: Center //OVE type: POINT //OVE shape: SQUARE //OVE default: (0.7, 0.5) //OVE description: uniform vec2 center; //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 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; 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; } } const float SQRT_2 = 1.414213562373; 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 x = opening ? progress : 1.-progress; float m = smoothstep(-smoothness, 0.0, SQRT_2*distance(fix_as(center), fix_as(uv)) - x*(1.+smoothness)); return mix(getFromColor(uv), getToColor(uv), opening ? 1.-m : m); } void main(void) { frag_color = transition( ove_texcoord.xy, TransformCurve(1.0 - ove_tprog_all)); }