Drizzle on the Commuter Glass
This one didn't compile in your browser.
Sourcegrid-cell refractive droplet lenses over horizontally drifting blurred bands and bokeh
precision mediump float;
uniform vec2 u_resolution;
uniform float u_time;
float hash(vec2 p){
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
}
float noise(vec2 p){
vec2 i = floor(p);
vec2 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
float a = hash(i);
float b = hash(i + vec2(1.0, 0.0));
float c = hash(i + vec2(0.0, 1.0));
float d = hash(i + vec2(1.0, 1.0));
return mix(mix(a, b, f.x), mix(c, d, f.x), f.y);
}
vec3 scene(vec2 p){
float t = u_time * 0.025;
float x = p.x + t;
vec3 sky = vec3(0.72, 0.75, 0.76);
vec3 mid = vec3(0.47, 0.54, 0.52);
vec3 low = vec3(0.35, 0.37, 0.41);
float h = 0.12 + 0.14 * noise(vec2(x * 2.2, 1.0));
vec3 c = mix(low, mid, smoothstep(-0.36, -0.14, p.y));
c = mix(c, sky, smoothstep(h - 0.08, h + 0.08, p.y));
float colm = noise(vec2(x * 5.0, 3.0));
float blk = smoothstep(0.4, 0.7, colm) * (1.0 - smoothstep(h - 0.1, h + 0.1, p.y)) * smoothstep(-0.3, 0.0, p.y);
c = mix(c, c * 0.82 + vec3(0.02, 0.03, 0.0), blk);
for (int i = 0; i < 5; i++) {
float fi = float(i);
float bx = mod(hash(vec2(fi, 2.0)) * 2.4 - t, 2.4) - 1.2;
vec2 c0 = vec2(bx, -0.14 + 0.2 * hash(vec2(fi, 5.0)));
float b = 1.0 - smoothstep(0.03, 0.09, length(p - c0));
c = mix(c, vec3(0.86, 0.66, 0.38), b * 0.5);
}
return c;
}
void main(){
vec2 uv = gl_FragCoord.xy / u_resolution;
vec2 p = (gl_FragCoord.xy - 0.5 * u_resolution) / u_resolution.y;
vec3 base = scene(p);
vec3 col = mix(base, vec3(0.78, 0.8, 0.8), 0.14);
const float GRID = 9.0;
vec2 g = p * GRID;
vec2 id = floor(g);
vec2 f = fract(g) - 0.5;
float h1 = hash(id);
float h2 = hash(id + 7.3);
float h3 = hash(id + 13.1);
float life = fract(u_time * 0.035 + h3);
float grow = smoothstep(0.0, 0.15, life) * (1.0 - smoothstep(0.6, 1.0, life));
float r = (0.12 + 0.16 * h1) * grow * step(0.35, h2);
vec2 o = vec2(h2 - 0.5, h1 - 0.5) * 0.35;
vec2 d = f - o;
d.y *= 1.1;
float dist = length(d);
float m = 1.0 - smoothstep(r - 0.08, r, dist);
vec2 q = p - (d / GRID) * 3.0;
vec3 dc = scene(q) * 1.06 + 0.03;
float rim = smoothstep(r - 0.12, r, dist);
float lowSide = clamp(-d.y / max(r, 0.001) * 1.5 + 0.3, 0.0, 1.0);
dc = mix(dc, dc * 0.68, rim * lowSide);
float hl = 1.0 - smoothstep(0.0, 0.08, length(d - vec2(-0.35, 0.4) * r));
dc += 0.22 * hl * step(0.05, r);
col = mix(col, dc, m);
float sh = (1.0 - smoothstep(0.0, 0.12, abs(dist - r - 0.03))) * step(0.0, -d.y) * step(0.05, r);
col *= 1.0 - 0.06 * sh * (1.0 - m);
float v = smoothstep(1.1, 0.3, length((uv - 0.5) * vec2(1.2, 1.0)));
col *= 0.86 + 0.14 * v;
gl_FragColor = vec4(col, 1.0);
}