#version 150 //OVE shader_name: Kaleidoscope //OVE shader_description: by nwoeanhinnogaehr (Licence MIT) //OVE name: Speed //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE max: 100.0 //OVE default: 1.0 //OVE description: uniform float speed; //OVE name: Angle //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE default: 1.0 //OVE description: uniform float angle; //OVE name: Power //OVE type: FLOAT //OVE flag: NOT_CONNECTABLE //OVE min: 0.0 //OVE max: 100.0 //OVE default: 1.5 //OVE description: uniform float power; //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; 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; } } vec4 transition(vec2 uv, float progress) { vec2 p = uv.xy / vec2(1.0).xy; vec2 q = p; float t = pow(progress, power)*speed; p = p -0.5; for (int i = 0; i < 7; i++) { p = vec2(sin(t)*p.x + cos(t)*p.y, sin(t)*p.y - cos(t)*p.x); t += angle; p = abs(mod(p, 2.0) - 1.0); } abs(mod(p, 1.0)); return mix( mix(getFromColor(q), getToColor(q), progress), mix(getFromColor(p), getToColor(p), progress), 1.0 - 2.0*abs(progress - 0.5)); } void main(void) { frag_color = transition( ove_texcoord.xy, TransformCurve(1.0 - ove_tprog_all)); }