51 lines
1.9 KiB
GLSL
51 lines
1.9 KiB
GLSL
// Slow colourful ocean for the chaos event: the palette drifts through the
|
|
// whole colour wheel over a few minutes, jellyfish glide along the stairs,
|
|
// plankton fades in and out. Nothing here moves fast.
|
|
|
|
float hash(float n) { return fract(sin(n * 12.9898) * 43758.5453); }
|
|
|
|
vec3 hsv(float h, float s, float v) {
|
|
vec3 rgb = clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0,
|
|
0.0, 1.0);
|
|
return v * mix(vec3(1.0), rgb, s);
|
|
}
|
|
|
|
// A jellyfish: soft blob that glides and breathes
|
|
vec3 jelly(float i, float t, float seed) {
|
|
float pos = 6.0 + 5.5 * sin(t * (0.07 + 0.03 * seed) + seed * 4.0);
|
|
float d = i - pos;
|
|
float breath = 0.55 + 0.45 * sin(t * 0.5 + seed * 3.0);
|
|
float hue = 0.85 + 0.35 * seed + t / 180.0; // contrasts with the water
|
|
return hsv(hue, 0.7, 1.0) * exp(-d * d * 0.55) * breath * 0.75;
|
|
}
|
|
|
|
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
|
|
float i = floor(fragCoord.x / iResolution.x * 16.0);
|
|
float t = iTime;
|
|
|
|
// waves, all slow
|
|
float w1 = 0.5 + 0.5 * sin(i * 0.55 - t * 0.45);
|
|
float w2 = 0.5 + 0.5 * sin(i * 0.90 + t * 0.30 + 1.0);
|
|
float w3 = 0.5 + 0.5 * sin(i * 0.25 - t * 0.17 + 2.5);
|
|
float h = 0.45 * w1 + 0.30 * w2 + 0.25 * w3;
|
|
|
|
// water colour: blue to magenta to teal, wheel drifts over 3 minutes
|
|
float hue = 0.58 + 0.22 * sin(i * 0.22 + t * 0.06) + 0.10 * h + t / 180.0;
|
|
vec3 col = hsv(hue, 0.95, 0.10 + 0.75 * h);
|
|
|
|
// foam on the crests
|
|
float foam = smoothstep(0.80, 0.97, h);
|
|
col = mix(col, vec3(0.9), foam * 0.7);
|
|
|
|
// jellyfish
|
|
col += jelly(i, t, 0.0) + jelly(i, t, 1.0);
|
|
|
|
// plankton, each step lights up now and then for ~12 s
|
|
float cyc = t * 0.08 + hash(i);
|
|
float cell = floor(cyc);
|
|
float life = sin(3.14159265 * fract(cyc));
|
|
float on = step(0.72, hash(i * 13.0 + cell));
|
|
col += hsv(hue + 0.5, 0.4, 1.0) * pow(life, 4.0) * on * 0.55;
|
|
|
|
fragColor = vec4(col, 1.0);
|
|
}
|