Pond Raindrop Ripples shader

pond-raindrop-ripples.glsl · 111 lines · GLSL ES 3.00 · MIT

Pond Raindrop RipplesWater & Ice
Pond Raindrop Ripples WebGL2 procedural shader preview
FPS 60BUFFER 960×540SOURCE 111 linesSPEC GLSL ES 3.00

Seamless PNG Texture Baker
1-Click Engine Shader Export
WebGL2 .glsl
.glsl
Godot 4 .gdshader
Three.js GLSL3

Engine shader code & wrappers

Dynamic Liquids
pond-raindrop-ripples.glsl (111 lines)
#version 300 es
// Pond Raindrop Ripples (pond-raindrop-ripples.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/liquids/lib/14_rain_rings_on_a_pond.glsl
// License: MIT (Copyright 2026 Gokay Aydogan) + MIT/CC0 helpers — https://pixelfx.io/LICENSE-SHADERS.txt
// Uniforms: uResolution (vec2), uTime (float)
// Hash adapted from David Hoskins, Hash without Sine. See THIRD_PARTY_NOTICES.md.
// Credits: https://github.com/gokayfem/glsl-studies/blob/main/credit.md#shader-liquids-lib-14-rain-rings-on-a-pond
// Woodland pond during light rain. Refracted leaf litter, reflected alder canopy.
// uResolution is the viewport size in pixels. Optional uTime is elapsed seconds (default 0).
precision highp float;
uniform vec2 uResolution;
uniform float uTime;
out vec4 fragColor;

float hash(vec2 p) {
    vec3 q = fract(p.xyx * vec3(.1031,.11369,.13787));
    q += dot(q,q.yzx+19.19);
    return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p) {
    vec2 i = floor(p), f = fract(p);
    f = f*f*(3.0-2.0*f);
    return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
               mix(hash(i+vec2(0,1)),hash(i+1.0),f.x),f.y);
}
vec2 sceneCoord() {
    return (2.0*gl_FragCoord.xy-uResolution)/max(1.0,min(uResolution.x,uResolution.y));
}

float fbm(vec2 p) {
    mat2 twist = mat2(1.68,1.20,-1.20,1.68);
    float sum = 0.0, amplitude = .53;
    for(int i=0;i<4;i++) {
        sum += amplitude*noise2(p);
        p = twist*p+vec2(3.2,7.1);
        amplitude *= .5;
    }
    return sum;
}
float sq(float x) { return x*x; }
mat2 rotate2(float a) {
    return mat2(cos(a),sin(a),-sin(a),cos(a));
}
float edgeMask(float d,float pixel) {
    return 1.0-smoothstep(-pixel,pixel,d);
}

vec3 litter(vec2 p,float seed) {
    vec3 mud = mix(vec3(.105,.105,.064),vec3(.34,.27,.15),fbm(p*5.0));
    mud *= .88+.22*noise2(p*98.0);
    vec2 g = p*1.8+seed;
    for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
        vec2 id = floor(g)+vec2(i,j);
        float s = hash(id+seed);
        if(s<.31) continue;
        vec2 leaf = rotate2(6.28*s)*(g-id-vec2(hash(id+2.1),hash(id+8.9)));
        leaf /= .64+.67*hash(id+1.7);
        float y = leaf.y+.105*leaf.x*leaf.x;
        float t = leaf.x/.40;
        float width = (.099+.10*s)*pow(max(0.0,1.0-t*t),.77);
        width *= .96+.04*cos(leaf.x*150.0);
        float edge = max(abs(y)-width,(abs(t)-1.0)*.40);
        float vein = abs(fract((leaf.x-.85*abs(y))*16.0)-.5);
        vec3 ochre = mix(vec3(.275,.146,.055),vec3(.65,.32,.093),s);
        vec3 tissue = ochre*(.59+.52*fbm(leaf*39.0)+.09*smoothstep(.002,.018,abs(y)));
        tissue += vec3(.10,.075,.031)*(exp(-sq(y/.004))+.45*exp(-sq(vein/.066)));
        mud *= 1.0-.17*edgeMask(edge-.012,.011);
        mud = mix(mud,tissue,edgeMask(edge,.004));
        float stem = max(abs(y)-.004,max(-leaf.x-.56,leaf.x+.39));
        mud = mix(mud,ochre*.85,edgeMask(stem,.004));
    }
    return mud;
}
vec3 canopy(vec3 reflected) {
    vec2 p = reflected.xy/max(.16,reflected.z);
    float leaves = fbm(p*2.8+2.3)+.12*noise2(p*24.0);
    float sky = smoothstep(.39,.69,leaves+.15*p.x);
    vec3 c = mix(vec3(.085,.14,.092),vec3(.69,.80,.88),sky);
    return c+vec3(.37,.27,.15)*exp(-dot(p-vec2(.20,.86),p-vec2(.20,.86))*5.0);
}
void main() {
    vec2 uv = sceneCoord();
    vec3 ray = normalize(vec3(.72*uv.x,.73+.55*uv.y,-1.0+.32*uv.y));
    vec2 p = (vec3(0,-1.05,1.55)-1.55/ray.z*ray).xy;
    vec2 slope = vec2(.014*sin(7.0*p.y+.27*uTime),.011*sin(p.x*9.0+2.0*p.y));
    float footprint = max(length(dFdx(p)),length(dFdy(p)));
    for(int j=-1;j<=1;j++) for(int i=-1;i<=1;i++) {
        vec2 id = floor(p)+vec2(i,j);
        float tick = .39*uTime+hash(id+9.7);
        vec2 event = id+floor(tick)*13.37;
        float t = fract(tick);
        vec2 delta = p-id-.13-.74*vec2(hash(event+1.1),hash(event+7.8));
        float r = length(delta);
        float wave = r-1.26*t;
        float packet = exp(-sq((wave+.086)/(.08+.07*t)));
        float phase = (59.0+12.0*hash(event))*wave+24.0*wave*wave;
        float life = smoothstep(.0,.09,t)*(1.0-smoothstep(.51,.97,t));
        slope += delta/max(r,.001)*(.15*life*packet*cos(phase)
                 +.33*exp(-sq((r-.062*t/.13)/.035))*exp(-21.0*t))
                 *exp(-sq(footprint*36.0));
    }
    vec3 n = normalize(vec3(-slope,1));
    vec3 under = refract(ray,n,1.0/1.333);
    float depth = .24+.29*noise2(p*1.7);
    vec2 floorHit = p-under.xy*depth/under.z;
    vec3 bottom = litter(floorHit,3.17);
    vec3 trans = exp(-depth*vec3(1.35,.75,.93)/abs(under.z));
    bottom = mix(vec3(.12,.23,.19),bottom,trans);
    float fresnel = .034+.89*pow(1.0-clamp(dot(-ray,n),0.0,1.0),4.4);
    vec3 reflection = canopy(reflect(ray,n));
    bottom *= .95+.08*noise2(floorHit*18.0);
    vec3 water = mix(bottom,reflection,clamp(fresnel*2.7+.14,0.0,.94));
    fragColor = vec4(water,1);
}

Mathematical models & shader specifications

Identifierpond-raindrop-ripples
CategoryWater & Ice Shaders · Dynamic Liquids
Upstream studyliquids/lib/14_rain_rings_on_a_pond.glsl (commit c3a6f6c)
Animation cycleContinuous procedural uTime
Declared uniformsuResolution, uTime
Source size111 lines · 4.4 KB standalone GLSL ES 3.00
PNG baker outputs512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key)
Companion pixel VFXFree MIT weather sprite sheets
LicenseMIT License + CC0 / MIT Helpers

Physical & shading models implemented

Procedural signed-distance and analytic surface shading

Adapted upstream mathematical helpers

David Hoskins, hash

All water & ice shaders