// Dark clouds with rare lightning float hash(float n) { return fract(sin(n * 12.9898) * 43758.5453); } float noise(float x) { float i = floor(x); float f = fract(x); return mix(hash(i), hash(i + 1.0), f * f * (3.0 - 2.0 * f)); } void mainImage(out vec4 fragColor, in vec2 fragCoord) { float i = floor(fragCoord.x / iResolution.x * 16.0); float cloud = 0.6 * noise(i * 0.4 - iTime * 0.25) + 0.4 * noise(i * 0.9 + iTime * 0.15 + 20.0); vec3 col = mix(vec3(0.0, 0.01, 0.04), vec3(0.07, 0.10, 0.22), cloud); // one strike per 14 s slot, 60% of the slots float slot = floor(iTime / 14.0); float local = iTime - (slot * 14.0 + 1.0 + hash(slot + 5.0) * 10.0); if (hash(slot + 9.0) < 0.6 && local > 0.0 && local < 1.2) { float bolt = floor(hash(slot + 13.0) * 12.0); // where it strikes float flash = exp(-local * 7.0) + 0.8 * exp(-abs(local - 0.22) * 14.0); float near = exp(-abs(i - bolt) * 0.5); col += vec3(0.75, 0.8, 1.0) * flash * (0.15 + 0.85 * near); } fragColor = vec4(col, 1.0); }