71337 Water Mites - Radical Ed
#define PERIOD 2.
#define REPETITIONS 2
const float PI = 3.1415926535;
float box(in vec2 _st, in vec2 _size){
_size = vec2(0.5) - _size*0.5;
vec2 uv = smoothstep(_size,
_size+vec2(0.001),
_st);
uv *= smoothstep(_size,
_size+vec2(0.001),
vec2(1.0)-_st);
return uv.x*uv.y;
}
float cross2(in vec2 _st, float _size){
return box(_st, vec2(_size,_size/4.)) +
box(_st, vec2(_size/4.,_size));
}
vec3 shadeBlob(vec2 p, float index, float value, float scale)
{
float screenRatio = iResolution.x / iResolution.y;
vec2 pc = vec2(0.1 + (screenRatio - 0.2) * value, index);
float d = length(pc - p) / 0.015*scale/0.3;
return vec3(3. * vec3(0.2, 0.5, 0.7) / (max(d * d, 1.)));
}
float step_interp(float x) {
return step(0.5, x);
}
float linear_interp(float x) {
float c = clamp(x, 0., 1.);
return c;
}
float cosine_interp(float x) {
float c = clamp(x, 0., 1.);
return 0.5 * (1. - cos(PI * c));
}
float smoothstep_interp(float x) {
// return smoothstep(0., 1., x);
float c = clamp(x, 0., 1.);
return c * c * (3. - 2. * c);
}
float quintic_interp(float x) {
float c = clamp(x, 0., 1.);
return c * c * c * ((6. * c - 15.) * c + 10.);
}
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 p = fragCoord.xy / iResolution.yy;
vec2 q = fragCoord.xy / iResolution.yy;
int tx = int(p.x*128.0);
// per lo Spectrum Audio
float wave = texelFetch( iChannel0, ivec2(tx,1), 0 ).x;
vec3 spec = vec3(wave);
vec2 translate = vec2(cos(iTime),sin(iTime));
vec2 translate2 = vec2(sin(iTime),cos(iTime));
p += translate*0.35*sin(iTime);
q += translate2*1.35*sin(iTime);
float t = abs(2. * fract(iTime / PERIOD) - 1.);
//int sel = int(6. * fract(time / (float(REPETITIONS) * PERIOD) / 6.));
int sel = 5;
// Background pattern
vec3 col = vec3(0.0 + 0.000 * mod(floor(p.x * 10.0) + floor(p.y * 10.0), 2.0));
vec3 col2 = vec3(0.0 + 0.000 * mod(floor(q.y * 5.0) + floor(q.x * 5.0), 2.0));
//vec3 col = vec3(0.0,0.0,0.0,0.0));
col += shadeBlob(p, 0.1, smoothstep_interp(t)*spec.x+0.5, wave/3.0);
col2 += shadeBlob(q, 0.3+spec.z, linear_interp(t)*spec.y+0.5, wave/3.0);
col += shadeBlob(p, 0.5+spec.x, cosine_interp(t)*spec.z+0.7, wave/3.0);
col2 += shadeBlob(q, 0.7, smoothstep_interp(t)*spec.z+0.1, wave/3.0);
col += shadeBlob(p, 0.9-spec.y, quintic_interp(t)*spec.z+0.3, wave/3.0);
col = pow(col, vec3(0.45));
col2 = pow(col2, vec3(0.45));
fragColor = vec4(col+col2, 1.0);
}