AnimatedClear shallow stream refracting submerged riverbed stones with stationary standing wave crests.
Water & Ice
pond-raindrop-ripples.glsl · 111 lines · GLSL ES 3.00 · MIT
#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);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Pond Raindrop Ripples — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/liquids/lib/14_rain_rings_on_a_pond.glsl (MIT License)
// Drive uTime from GDScript if animating helper functions: material.set_shader_parameter("uTime", Time.get_ticks_msec() * 0.001 * u_speed)
uniform vec2 uResolution = vec2(1024.0, 1024.0);
uniform float uTime = 1.2;
uniform float u_speed : hint_range(0.0, 3.0, 0.05) = 1.0;
uniform float u_tiling : hint_range(0.25, 8.0, 0.25) = 1.0;
uniform vec4 u_tint : source_color = vec4(1.0, 0.722, 0.42, 1.0);
uniform float u_tint_mix : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform float uOpen : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform int uLightMode : hint_range(0, 3, 1) = 0;
uniform int uCamMode : hint_range(0, 1, 1) = 1;
uniform bool u_luma_alpha_key = false;
// 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).
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*pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
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);
}
void fragment() {
vec2 tiled_uv = fract(UV * u_tiling);
vec2 frag_xy = vec2(tiled_uv.x, 1.0 - tiled_uv.y) * uResolution;
vec4 study_col = vec4(0.0, 0.0, 0.0, 1.0);
pixelfx_study_eval(frag_xy, study_col);
vec3 tinted = clamp(mix(study_col.rgb, study_col.rgb * u_tint.rgb * 1.35, u_tint_mix), 0.0, 1.0);
float out_alpha = study_col.a * COLOR.a;
if (u_luma_alpha_key) {
float luma = dot(tinted, vec3(0.2126, 0.7152, 0.0722));
out_alpha *= smoothstep(0.035, 0.22, luma);
}
COLOR = vec4(tinted, out_alpha);
}
shader_type spatial;
render_mode cull_disabled;
// Pond Raindrop Ripples — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/liquids/lib/14_rain_rings_on_a_pond.glsl (MIT License)
// Drive uTime from GDScript if animating helper functions: material.set_shader_parameter("uTime", Time.get_ticks_msec() * 0.001 * u_speed)
uniform vec2 uResolution = vec2(1024.0, 1024.0);
uniform float uTime = 1.2;
uniform float u_speed : hint_range(0.0, 3.0, 0.05) = 1.0;
uniform float u_tiling : hint_range(0.25, 8.0, 0.25) = 1.0;
uniform vec4 u_tint : source_color = vec4(1.0, 0.722, 0.42, 1.0);
uniform float u_tint_mix : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform float uOpen : hint_range(0.0, 1.0, 0.01) = 0.0;
uniform int uLightMode : hint_range(0, 3, 1) = 0;
uniform int uCamMode : hint_range(0, 1, 1) = 1;
uniform bool u_luma_alpha_key = false;
// 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).
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*pfx_frag_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 pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor) {
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);
}
void fragment() {
vec2 tiled_uv = fract(UV * u_tiling);
vec2 frag_xy = vec2(tiled_uv.x, 1.0 - tiled_uv.y) * uResolution;
vec4 study_col = vec4(0.0, 0.0, 0.0, 1.0);
pixelfx_study_eval(frag_xy, study_col);
vec3 tinted = clamp(mix(study_col.rgb, study_col.rgb * u_tint.rgb * 1.35, u_tint_mix), 0.0, 1.0);
float luma = dot(tinted, vec3(0.2126, 0.7152, 0.0722));
ALBEDO = tinted;
ROUGHNESS = clamp(0.85 - luma * 0.45, 0.08, 0.96);
METALLIC = 0.04;
EMISSION = tinted * 0.0;
}
// Pond Raindrop Ripples — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/liquids/lib/14_rain_rings_on_a_pond.glsl (MIT License)
import * as THREE from 'three';
const vertexShader = /* glsl */ `
out vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`;
const fragmentShader = /* glsl */ `
// 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);
}
`;
export function createPondRaindropRipplesMaterial(width = 1024, height = 1024) {
const material = new THREE.ShaderMaterial({
glslVersion: THREE.GLSL3,
vertexShader,
fragmentShader,
uniforms: {
uResolution: { value: new THREE.Vector2(width, height) },
uTime: { value: 1.2 },
uOpen: { value: 0.0 },
uLightMode: { value: 0 },
uCamMode: { value: 1 },
},
});
return {
material,
update(elapsedSeconds) {
material.uniforms.uTime.value = elapsedSeconds * 1.0;
},
resize(nextW, nextH) {
material.uniforms.uResolution.value.set(nextW, nextH);
},
};
}
| Identifier | pond-raindrop-ripples |
|---|---|
| Category | Water & Ice Shaders · Dynamic Liquids |
| Upstream study | liquids/lib/14_rain_rings_on_a_pond.glsl (commit c3a6f6c) |
| Animation cycle | Continuous procedural uTime |
| Declared uniforms | uResolution, uTime |
| Source size | 111 lines · 4.4 KB standalone GLSL ES 3.00 |
| PNG baker outputs | 512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key) |
| Companion pixel VFX | Free MIT weather sprite sheets |
| License | MIT License + CC0 / MIT Helpers |
Procedural signed-distance and analytic surface shading
David Hoskins, hash
AnimatedClear shallow stream refracting submerged riverbed stones with stationary standing wave crests.
AnimatedVoronoi-stretched white surf foam webbing floating over aerated turquoise seawater.
AnimatedPolyhedral soap-bubble cluster with Plateau liquid borders and thin-film rainbow interference.
PBR StudyClear refractive ice stalactites with characteristic centimetre-scale horizontal growth ribs.
PBR StudyFeathery granular rime ice feathers accreting into freezing alpine wind.
PBR StudyRounded polar ice plates with collision-raised slush rims floating on dark frigid water.