#version 150 //OVE shader_name: Random Squares //OVE shader_description: by gre (Licence MIT) //OVE name: Number //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.1 //OVE max: 200.0 //OVE default: 10.0 //OVE description: uniform float size; //OVE name: Smoothness //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0 //OVE max: 10 //OVE default: 0.5 //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; /* 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 rand (vec2 co) { return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); } vec4 transition(vec2 p) { float r = rand(floor(vec2(size) * p)); float m = smoothstep(0.0, -smoothness, r - (progress * (1.0 + smoothness))); return mix(getFromColor(p), getToColor(p), m); } void main(void) { progress = TransformCurve(1.0 - ove_tprog_all); frag_color = transition( ove_texcoord.xy); }