Raw gif (gif) -
Video (mp4) -
Video (ogv) -
Preview (png)
language: shader_webgl1
precision highp float;
varying vec2 UV;
uniform float ratio;
uniform float time;
#define PI 3.14159265359
#define PI2 6.28
#define angle(p) atan(p.y, p.x)
vec4 dither(vec4 in_col){
vec4 col = vec4(0.0);
float x = UV.x * 540.0;
float y = UV.y * 540.0;
float divisions = 3.0;
x += 0.07 * cos(time * 6.28 + y * 0.01);
if(mod(x, divisions) < length(in_col.r)*divisions){
if(mod(y, divisions) < length(in_col.r)*divisions){
col.r += 1.0;
}
}
if(mod(x, divisions) < length(in_col.g)*divisions){
if(mod(y, divisions) < length(in_col.g)*divisions){
col.g += 1.0;
}
}
if(mod(x, divisions) < length(in_col.b)*divisions){
if(mod(y, divisions) < length(in_col.b)*divisions){
col.b += 1.0;
}
}
return col;
}
/*
Complex square
*/
vec2 to_the_2(vec2 z){
highp vec2 old_z;
// Keep the current (old) value
old_z = z;
// Set new values according to math
z.x = pow(z.x,2.0) - pow(z.y,2.0);
z.y = 2.0 * old_z.x * old_z.y;
return z;
}
#define iterations 700
void main(void){
vec4 col = vec4(0.0);
vec2 p = (UV - 0.5) * 5.0 - vec2(0.5, 0.0);
p *= 0.2 - 0.198 * cos(time * 6.28);
p.x -= 0.7;
p.y += 0.3;
vec2 curr = vec2(0.0,0.0);
int maxit = 0;
for(int i = 0; i < iterations; i++){
curr = to_the_2(curr) + p;
if(length(curr) > 2.0){
maxit = i;
break;
}
}
if(maxit > 1){
if(maxit == int(float(iterations))){
col.rgb += 0.3;
}
}
col.r += length(float(maxit) / float(iterations));
col = dither(col);
col.a = 1.0;
gl_FragColor = col;
}