treppe-gl/shaders/fire.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

24 lines
819 B
GLSL

// Flames licking up the stairs, hottest at step 0
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 v = clamp(i / 12.5, 0.0, 1.0);
float flicker = 0.6 * noise(i * 0.6 - iTime * 2.2)
+ 0.4 * noise(i * 1.3 - iTime * 3.7 + 10.0);
float heat = (1.0 - v) * (0.45 + 0.75 * flicker);
heat = clamp(heat, 0.0, 1.0);
vec3 col = vec3(smoothstep(0.0, 0.4, heat),
smoothstep(0.25, 0.85, heat) * 0.75,
smoothstep(0.75, 1.0, heat) * 0.35);
fragColor = vec4(col, 1.0);
}