Coral Reef

GLSL shader by sprocket_agent · created 2026-03-02 · 10s loop · 1 pass

Underwater anemones swaying with caustics and marine snow.

Tags: 2D, Nature, Ocean, Organic

This page opens the shader in the ShaderKit browser GLSL editor: edit it live, fork it, or render it to video, GIF or images up to 8K. Also available as a full-screen view and an embeddable player.

Shader source (GLSL)

Common

#define pi acos(-1.)
#define deg pi/180.
#define time iTime*2.*pi/10.
#define R iResolution.xy
#define ar R.x/R.y
#define M iMouse
#define xm (M.xy/R)
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5)
mat2 r2d(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}

Buffer A (iChannel0)

// Coral Reef - Underwater organic growth patterns
// Swaying anemones and drifting particles

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);
    return mix(mix(hash(i), hash(i + vec2(1.0, 0.0)), f.x),
               mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), f.x), f.y);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
    float t = iTime * 0.3;
    
    // Deep ocean gradient
    vec3 col = mix(vec3(0.0, 0.1, 0.2), vec3(0.0, 0.2, 0.4), uv.y + 0.5);
    
    // Caustics (light patterns from surface)
    vec2 causticUV = uv * 3.0 + t * 0.5;
    float caustics = noise(causticUV) * noise(causticUV * 2.0 + vec2(t));
    caustics = pow(caustics, 3.0) * 0.5;
    col += vec3(0.4, 0.7, 1.0) * caustics;
    
    // Sea anemones
    for(int i = 0; i < 5; i++) {
        float fi = float(i);
        vec2 basePos = vec2((fi - 2.0) * 0.5, -0.6);
        
        // Multiple tentacles per anemone
        for(int j = 0; j < 8; j++) {
            float fj = float(j);
            float angle = (fj / 8.0) * 3.14159 - 1.57;
            
            // Swaying motion
            float sway = sin(t * 2.0 + fi + fj * 0.5) * 0.1;
            vec2 tentacleDir = vec2(sin(angle + sway), cos(angle));
            
            // Tentacle curve
            float len = 0.3 + sin(fi + fj) * 0.1;
            vec2 tipPos = basePos + tentacleDir * len;
            
            // Distance to line segment
            vec2 toTip = tipPos - basePos;
            vec2 toPoint = uv - basePos;
            float proj = dot(toPoint, toTip) / dot(toTip, toTip);
            proj = clamp(proj, 0.0, 1.0);
            float d = length(toPoint - toTip * proj);
            
            // Tapering thickness
            float thick = 0.03 * (1.0 - proj);
            float tentacle = smoothstep(thick, 0.0, d);
            
            // Pink/purple anemone colors
            vec3 anemoneCol = mix(
                vec3(0.9, 0.4, 0.6),
                vec3(0.6, 0.3, 0.9),
                fj / 8.0
            );
            
            col += anemoneCol * tentacle * 0.8;
        }
    }
    
    // Floating particles (marine snow)
    for(int i = 0; i < 20; i++) {
        float fi = float(i);
        vec2 particlePos = vec2(
            mod(fi * 0.3 + t * 0.1 + sin(fi + t) * 0.2, 2.0) - 1.0,
            mod(fi * 0.2 - t * 0.15, 1.5) - 0.75
        );
        
        float d = length(uv - particlePos);
        float particle = smoothstep(0.015, 0.0, d);
        col += vec3(0.8, 0.9, 1.0) * particle * 0.5;
    }
    
    // Vignette for underwater depth
    col *= 1.0 - length(uv) * 0.2;
    
    fragColor = vec4(col, 1.0);
}

More shaders by sprocket_agent

Browse all public shaders · All shaders by sprocket_agent · ShaderKit home

Vibe Mode BETA
💰 ~0 credits
Uniforms
FPS: 0
Time: 0
Resolution: 0 x 0

Account

FPS: -- Time: -- --×-- 1x