treppe-gl/shaders/storm.glsl
April John cebb41dbc7 Add fire, ocean, heartbeat, bounce, trans and storm shaders
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 15:03:47 +02:00

28 lines
1.1 KiB
GLSL

// 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);
}