AnimatedAnimated Rayleigh-instability liquid crown rim ejecting droplets over concentric pond ripples.
Water & Ice
glacial-meltwater-channels.glsl · 98 lines · GLSL ES 3.00 · MIT
#version 300 es
// Glacial Meltwater Channels (glacial-meltwater-channels.glsl)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/ice/lib/11_meltwater_channels_incised_into_ice.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-ice-lib-11-meltwater-channels-incised-into-ice
// Supraglacial stream | near-vertical ice banks enclosing a lower water surface.
// uResolution: viewport in pixels. No optional uniforms.
precision highp float;
uniform vec2 uResolution;
out vec4 fragColor;
const float PI=3.14159265;
const float TAU=6.28318531;
float hash(vec2 p){
vec3 q=fract(vec3(p.xyx)*vec3(.1031,.1030,.0973));
q+=dot(q,q.yzx+33.33);
return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p){
vec2 i=floor(p),f=fract(p);
f=f*f*(3.-2.*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
mix(hash(i+vec2(0,1)),hash(i+1.),f.x),f.y);
}
float fbm(vec2 p){
mat2 turn=mat2(.8,.6,-.6,.8);
return .55*noise2(p)+.27*noise2(turn*p*2.13+5.)
+.13*noise2(p*4.57-9.)+.05*noise2(turn*p*9.12);
}
float gauss(float x){return exp(-x*x);}
float pixel(){return 2./min(uResolution.x,uResolution.y);}
vec2 viewport(){return (2.*gl_FragCoord.xy-uResolution)*(.5*pixel());}
float center(float y){return .29*sin(2.8*y+.46)+.11*sin(5.4*y-.35)-.12*y;}
float channel(vec2 p){
float x=p.x-center(p.y);
float width=.249+.068*sin(2.1*p.y+.3)+.048*gauss(2.*(p.y+.3));
float mainCut=abs(x)-width;
float tributary=abs(p.y-.35-.80*x-.071*sin(6.*x))-.113;
return min(mainCut,max(tributary,-x))+.014*(noise2(p*16.)-.5);
}
float top(vec2 p){return .142+.060*fbm(p*3.2)+.007*noise2(p*23.);}
float solid(vec2 p){
float d=channel(p);
float erosion=smoothstep(-.061,.050,d);
return mix(-.28+.037*noise2(p*11.),top(p),erosion);
}
vec3 shade(vec2 screen){
vec2 uv=screen*1.04;
// Camera looks across and down the stream. One bank occludes parts of
// the water and the steep opposite face remains visible above its waterline.
vec2 drift=vec2(.47,.62);
const float waterLevel=-.063;
float hi=.36,lo=hi;
for(int i=0;i<48;i++){
lo=hi-.016;
if(lo<=max(waterLevel,solid(uv-lo*drift)))break;
hi=lo;
}
for(int i=0;i<6;i++){
float m=(hi+lo)*.5;
if(m>max(waterLevel,solid(uv-m*drift)))hi=m;else lo=m;
}
float h=(lo+hi)*.5; vec2 p=uv-h*drift;
float d=channel(p),crest=top(p),bank=1.-smoothstep(.012,.086,h-crest+.087);
float water=1.-smoothstep(.0004,.0025,h-waterLevel);
vec2 q=vec2(p.x+.074*sin(p.y*3.)+.04*noise2(p*7.),p.y);
float bubbles=fbm(q*vec2(21.,55.));
vec2 flow=vec2(p.x-center(p.y),p.y);
float wave=fbm(flow*vec2(22.,55.)+1.1*noise2(flow*12.));
float ripple=sin(93.*p.y+11.*sin(12.*p.x+4.*p.y)+7.*noise2(p*16.));
vec3 pos=vec3(p,h+.0021*bubbles+.0015*ripple*water);
vec3 n=normalize(cross(dFdx(pos),dFdy(pos)));
vec3 sun=normalize(vec3(-.66,.43,.71));
float diffuse=max(dot(n,sun),0.);
float seam=gauss((h-.075-.034*sin(p.y*3.1)-.022*noise2(p*7.))/.011);
float chip=noise2(p*136.);
float layers=fbm(q*vec2(36.,4.)+.53*fbm(p*8.));
float hairline=gauss((p.x+.54+.16*p.y+.071*sin(5.*p.y)+.014*noise2(p*26.))/.006);
vec3 ice=mix(vec3(.51,.72,.80),vec3(.94,.97,.97),.58*bubbles+.42*layers);
ice*=1.-.17*hairline;
float wallGrain=fbm(vec2(p.y*19.+p.x*9.,h*21.));
float inclusions=smoothstep(.56,.71,fbm(vec2(p.y*130.,h*145.)));
vec3 wall=mix(vec3(.25,.55,.65),vec3(.63,.83,.85),wallGrain)+.09*seam+.09*inclusions;
vec3 c=mix(ice,wall,bank)*(.78+.32*diffuse)+.019*(chip-.5);
float depth=waterLevel-solid(p+vec2(.018,.012));
vec3 liquid=mix(vec3(.28,.67,.66),vec3(.025,.36,.47),smoothstep(0.,.22,depth));
float shoreShadow=exp(-abs(d+.064)*7.)*(.5+.5*sin(p.y*4.));
liquid*=.92-.32*shoreShadow;
float sky=wave*.64+.36*noise2(flow*vec2(8.,17.));
liquid+=vec3(.15,.21,.20)*smoothstep(.31,.72,sky);
liquid+=vec3(.13,.18,.16)*smoothstep(.54,.74,wave)*smoothstep(.25,.97,ripple);
c=mix(c,liquid,water);
return c;
}
void main(){
vec2 p=viewport(), offset=pixel()*vec2(.24,.17);
fragColor=vec4(.5*(shade(p-offset)+shade(p+offset)),1.);
}
shader_type canvas_item;
// Attach to a ColorRect, Sprite2D, or SubViewport texture baker in Godot 4.2+.
// Glacial Meltwater Channels — Godot 4 (canvas_item) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/ice/lib/11_meltwater_channels_incised_into_ice.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-ice-lib-11-meltwater-channels-incised-into-ice
// Supraglacial stream | near-vertical ice banks enclosing a lower water surface.
// uResolution: viewport in pixels. No optional uniforms.
const float PI=3.14159265;
const float TAU=6.28318531;
float hash(vec2 p){
vec3 q=fract(vec3(p.xyx)*vec3(.1031,.1030,.0973));
q+=dot(q,q.yzx+33.33);
return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p){
vec2 i=floor(p),f=fract(p);
f=f*f*(3.-2.*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
mix(hash(i+vec2(0,1)),hash(i+1.),f.x),f.y);
}
float fbm(vec2 p){
mat2 turn=mat2(.8,.6,-.6,.8);
return .55*noise2(p)+.27*noise2(turn*p*2.13+5.)
+.13*noise2(p*4.57-9.)+.05*noise2(turn*p*9.12);
}
float gauss(float x){return exp(-x*x);}
float pixel(){return 2./min(uResolution.x,uResolution.y);}
vec2 viewport(){return (2.*pfx_frag_xy-uResolution)*(.5*pixel());}
float center(float y){return .29*sin(2.8*y+.46)+.11*sin(5.4*y-.35)-.12*y;}
float channel(vec2 p){
float x=p.x-center(p.y);
float width=.249+.068*sin(2.1*p.y+.3)+.048*gauss(2.*(p.y+.3));
float mainCut=abs(x)-width;
float tributary=abs(p.y-.35-.80*x-.071*sin(6.*x))-.113;
return min(mainCut,max(tributary,-x))+.014*(noise2(p*16.)-.5);
}
float top(vec2 p){return .142+.060*fbm(p*3.2)+.007*noise2(p*23.);}
float solid(vec2 p){
float d=channel(p);
float erosion=smoothstep(-.061,.050,d);
return mix(-.28+.037*noise2(p*11.),top(p),erosion);
}
vec3 shade(vec2 screen){
vec2 uv=screen*1.04;
// Camera looks across and down the stream. One bank occludes parts of
// the water and the steep opposite face remains visible above its waterline.
vec2 drift=vec2(.47,.62);
const float waterLevel=-.063;
float hi=.36,lo=hi;
for(int i=0;i<48;i++){
lo=hi-.016;
if(lo<=max(waterLevel,solid(uv-lo*drift)))break;
hi=lo;
}
for(int i=0;i<6;i++){
float m=(hi+lo)*.5;
if(m>max(waterLevel,solid(uv-m*drift)))hi=m;else lo=m;
}
float h=(lo+hi)*.5; vec2 p=uv-h*drift;
float d=channel(p),crest=top(p),bank=1.-smoothstep(.012,.086,h-crest+.087);
float water=1.-smoothstep(.0004,.0025,h-waterLevel);
vec2 q=vec2(p.x+.074*sin(p.y*3.)+.04*noise2(p*7.),p.y);
float bubbles=fbm(q*vec2(21.,55.));
vec2 flow=vec2(p.x-center(p.y),p.y);
float wave=fbm(flow*vec2(22.,55.)+1.1*noise2(flow*12.));
float ripple=sin(93.*p.y+11.*sin(12.*p.x+4.*p.y)+7.*noise2(p*16.));
vec3 pos=vec3(p,h+.0021*bubbles+.0015*ripple*water);
vec3 n=normalize(cross(dFdx(pos),dFdy(pos)));
vec3 sun=normalize(vec3(-.66,.43,.71));
float diffuse=max(dot(n,sun),0.);
float seam=gauss((h-.075-.034*sin(p.y*3.1)-.022*noise2(p*7.))/.011);
float chip=noise2(p*136.);
float layers=fbm(q*vec2(36.,4.)+.53*fbm(p*8.));
float hairline=gauss((p.x+.54+.16*p.y+.071*sin(5.*p.y)+.014*noise2(p*26.))/.006);
vec3 ice=mix(vec3(.51,.72,.80),vec3(.94,.97,.97),.58*bubbles+.42*layers);
ice*=1.-.17*hairline;
float wallGrain=fbm(vec2(p.y*19.+p.x*9.,h*21.));
float inclusions=smoothstep(.56,.71,fbm(vec2(p.y*130.,h*145.)));
vec3 wall=mix(vec3(.25,.55,.65),vec3(.63,.83,.85),wallGrain)+.09*seam+.09*inclusions;
vec3 c=mix(ice,wall,bank)*(.78+.32*diffuse)+.019*(chip-.5);
float depth=waterLevel-solid(p+vec2(.018,.012));
vec3 liquid=mix(vec3(.28,.67,.66),vec3(.025,.36,.47),smoothstep(0.,.22,depth));
float shoreShadow=exp(-abs(d+.064)*7.)*(.5+.5*sin(p.y*4.));
liquid*=.92-.32*shoreShadow;
float sky=wave*.64+.36*noise2(flow*vec2(8.,17.));
liquid+=vec3(.15,.21,.20)*smoothstep(.31,.72,sky);
liquid+=vec3(.13,.18,.16)*smoothstep(.54,.74,wave)*smoothstep(.25,.97,ripple);
c=mix(c,liquid,water);
return c;
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
vec2 p=viewport(), offset=pixel()*vec2(.24,.17);
fragColor=vec4(.5*(shade(p-offset)+shade(p+offset)),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;
// Glacial Meltwater Channels — Godot 4 (spatial) wrapper
// Source: https://github.com/gokayfem/glsl-studies/blob/main/ice/lib/11_meltwater_channels_incised_into_ice.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-ice-lib-11-meltwater-channels-incised-into-ice
// Supraglacial stream | near-vertical ice banks enclosing a lower water surface.
// uResolution: viewport in pixels. No optional uniforms.
const float PI=3.14159265;
const float TAU=6.28318531;
float hash(vec2 p){
vec3 q=fract(vec3(p.xyx)*vec3(.1031,.1030,.0973));
q+=dot(q,q.yzx+33.33);
return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p){
vec2 i=floor(p),f=fract(p);
f=f*f*(3.-2.*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
mix(hash(i+vec2(0,1)),hash(i+1.),f.x),f.y);
}
float fbm(vec2 p){
mat2 turn=mat2(.8,.6,-.6,.8);
return .55*noise2(p)+.27*noise2(turn*p*2.13+5.)
+.13*noise2(p*4.57-9.)+.05*noise2(turn*p*9.12);
}
float gauss(float x){return exp(-x*x);}
float pixel(){return 2./min(uResolution.x,uResolution.y);}
vec2 viewport(){return (2.*pfx_frag_xy-uResolution)*(.5*pixel());}
float center(float y){return .29*sin(2.8*y+.46)+.11*sin(5.4*y-.35)-.12*y;}
float channel(vec2 p){
float x=p.x-center(p.y);
float width=.249+.068*sin(2.1*p.y+.3)+.048*gauss(2.*(p.y+.3));
float mainCut=abs(x)-width;
float tributary=abs(p.y-.35-.80*x-.071*sin(6.*x))-.113;
return min(mainCut,max(tributary,-x))+.014*(noise2(p*16.)-.5);
}
float top(vec2 p){return .142+.060*fbm(p*3.2)+.007*noise2(p*23.);}
float solid(vec2 p){
float d=channel(p);
float erosion=smoothstep(-.061,.050,d);
return mix(-.28+.037*noise2(p*11.),top(p),erosion);
}
vec3 shade(vec2 screen){
vec2 uv=screen*1.04;
// Camera looks across and down the stream. One bank occludes parts of
// the water and the steep opposite face remains visible above its waterline.
vec2 drift=vec2(.47,.62);
const float waterLevel=-.063;
float hi=.36,lo=hi;
for(int i=0;i<48;i++){
lo=hi-.016;
if(lo<=max(waterLevel,solid(uv-lo*drift)))break;
hi=lo;
}
for(int i=0;i<6;i++){
float m=(hi+lo)*.5;
if(m>max(waterLevel,solid(uv-m*drift)))hi=m;else lo=m;
}
float h=(lo+hi)*.5; vec2 p=uv-h*drift;
float d=channel(p),crest=top(p),bank=1.-smoothstep(.012,.086,h-crest+.087);
float water=1.-smoothstep(.0004,.0025,h-waterLevel);
vec2 q=vec2(p.x+.074*sin(p.y*3.)+.04*noise2(p*7.),p.y);
float bubbles=fbm(q*vec2(21.,55.));
vec2 flow=vec2(p.x-center(p.y),p.y);
float wave=fbm(flow*vec2(22.,55.)+1.1*noise2(flow*12.));
float ripple=sin(93.*p.y+11.*sin(12.*p.x+4.*p.y)+7.*noise2(p*16.));
vec3 pos=vec3(p,h+.0021*bubbles+.0015*ripple*water);
vec3 n=normalize(cross(dFdx(pos),dFdy(pos)));
vec3 sun=normalize(vec3(-.66,.43,.71));
float diffuse=max(dot(n,sun),0.);
float seam=gauss((h-.075-.034*sin(p.y*3.1)-.022*noise2(p*7.))/.011);
float chip=noise2(p*136.);
float layers=fbm(q*vec2(36.,4.)+.53*fbm(p*8.));
float hairline=gauss((p.x+.54+.16*p.y+.071*sin(5.*p.y)+.014*noise2(p*26.))/.006);
vec3 ice=mix(vec3(.51,.72,.80),vec3(.94,.97,.97),.58*bubbles+.42*layers);
ice*=1.-.17*hairline;
float wallGrain=fbm(vec2(p.y*19.+p.x*9.,h*21.));
float inclusions=smoothstep(.56,.71,fbm(vec2(p.y*130.,h*145.)));
vec3 wall=mix(vec3(.25,.55,.65),vec3(.63,.83,.85),wallGrain)+.09*seam+.09*inclusions;
vec3 c=mix(ice,wall,bank)*(.78+.32*diffuse)+.019*(chip-.5);
float depth=waterLevel-solid(p+vec2(.018,.012));
vec3 liquid=mix(vec3(.28,.67,.66),vec3(.025,.36,.47),smoothstep(0.,.22,depth));
float shoreShadow=exp(-abs(d+.064)*7.)*(.5+.5*sin(p.y*4.));
liquid*=.92-.32*shoreShadow;
float sky=wave*.64+.36*noise2(flow*vec2(8.,17.));
liquid+=vec3(.15,.21,.20)*smoothstep(.31,.72,sky);
liquid+=vec3(.13,.18,.16)*smoothstep(.54,.74,wave)*smoothstep(.25,.97,ripple);
c=mix(c,liquid,water);
return c;
}
void pixelfx_study_eval(vec2 pfx_frag_xy, out vec4 fragColor){
vec2 p=viewport(), offset=pixel()*vec2(.24,.17);
fragColor=vec4(.5*(shade(p-offset)+shade(p+offset)),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;
}
// Glacial Meltwater Channels — Three.js WebGL2 ShaderMaterial (GLSL3)
// Upstream study: https://github.com/gokayfem/glsl-studies/blob/main/ice/lib/11_meltwater_channels_incised_into_ice.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-ice-lib-11-meltwater-channels-incised-into-ice
// Supraglacial stream | near-vertical ice banks enclosing a lower water surface.
// uResolution: viewport in pixels. No optional uniforms.
precision highp float;
uniform vec2 uResolution;
out vec4 fragColor;
const float PI=3.14159265;
const float TAU=6.28318531;
float hash(vec2 p){
vec3 q=fract(vec3(p.xyx)*vec3(.1031,.1030,.0973));
q+=dot(q,q.yzx+33.33);
return fract((q.x+q.y)*q.z);
}
float noise2(vec2 p){
vec2 i=floor(p),f=fract(p);
f=f*f*(3.-2.*f);
return mix(mix(hash(i),hash(i+vec2(1,0)),f.x),
mix(hash(i+vec2(0,1)),hash(i+1.),f.x),f.y);
}
float fbm(vec2 p){
mat2 turn=mat2(.8,.6,-.6,.8);
return .55*noise2(p)+.27*noise2(turn*p*2.13+5.)
+.13*noise2(p*4.57-9.)+.05*noise2(turn*p*9.12);
}
float gauss(float x){return exp(-x*x);}
float pixel(){return 2./min(uResolution.x,uResolution.y);}
vec2 viewport(){return (2.*gl_FragCoord.xy-uResolution)*(.5*pixel());}
float center(float y){return .29*sin(2.8*y+.46)+.11*sin(5.4*y-.35)-.12*y;}
float channel(vec2 p){
float x=p.x-center(p.y);
float width=.249+.068*sin(2.1*p.y+.3)+.048*gauss(2.*(p.y+.3));
float mainCut=abs(x)-width;
float tributary=abs(p.y-.35-.80*x-.071*sin(6.*x))-.113;
return min(mainCut,max(tributary,-x))+.014*(noise2(p*16.)-.5);
}
float top(vec2 p){return .142+.060*fbm(p*3.2)+.007*noise2(p*23.);}
float solid(vec2 p){
float d=channel(p);
float erosion=smoothstep(-.061,.050,d);
return mix(-.28+.037*noise2(p*11.),top(p),erosion);
}
vec3 shade(vec2 screen){
vec2 uv=screen*1.04;
// Camera looks across and down the stream. One bank occludes parts of
// the water and the steep opposite face remains visible above its waterline.
vec2 drift=vec2(.47,.62);
const float waterLevel=-.063;
float hi=.36,lo=hi;
for(int i=0;i<48;i++){
lo=hi-.016;
if(lo<=max(waterLevel,solid(uv-lo*drift)))break;
hi=lo;
}
for(int i=0;i<6;i++){
float m=(hi+lo)*.5;
if(m>max(waterLevel,solid(uv-m*drift)))hi=m;else lo=m;
}
float h=(lo+hi)*.5; vec2 p=uv-h*drift;
float d=channel(p),crest=top(p),bank=1.-smoothstep(.012,.086,h-crest+.087);
float water=1.-smoothstep(.0004,.0025,h-waterLevel);
vec2 q=vec2(p.x+.074*sin(p.y*3.)+.04*noise2(p*7.),p.y);
float bubbles=fbm(q*vec2(21.,55.));
vec2 flow=vec2(p.x-center(p.y),p.y);
float wave=fbm(flow*vec2(22.,55.)+1.1*noise2(flow*12.));
float ripple=sin(93.*p.y+11.*sin(12.*p.x+4.*p.y)+7.*noise2(p*16.));
vec3 pos=vec3(p,h+.0021*bubbles+.0015*ripple*water);
vec3 n=normalize(cross(dFdx(pos),dFdy(pos)));
vec3 sun=normalize(vec3(-.66,.43,.71));
float diffuse=max(dot(n,sun),0.);
float seam=gauss((h-.075-.034*sin(p.y*3.1)-.022*noise2(p*7.))/.011);
float chip=noise2(p*136.);
float layers=fbm(q*vec2(36.,4.)+.53*fbm(p*8.));
float hairline=gauss((p.x+.54+.16*p.y+.071*sin(5.*p.y)+.014*noise2(p*26.))/.006);
vec3 ice=mix(vec3(.51,.72,.80),vec3(.94,.97,.97),.58*bubbles+.42*layers);
ice*=1.-.17*hairline;
float wallGrain=fbm(vec2(p.y*19.+p.x*9.,h*21.));
float inclusions=smoothstep(.56,.71,fbm(vec2(p.y*130.,h*145.)));
vec3 wall=mix(vec3(.25,.55,.65),vec3(.63,.83,.85),wallGrain)+.09*seam+.09*inclusions;
vec3 c=mix(ice,wall,bank)*(.78+.32*diffuse)+.019*(chip-.5);
float depth=waterLevel-solid(p+vec2(.018,.012));
vec3 liquid=mix(vec3(.28,.67,.66),vec3(.025,.36,.47),smoothstep(0.,.22,depth));
float shoreShadow=exp(-abs(d+.064)*7.)*(.5+.5*sin(p.y*4.));
liquid*=.92-.32*shoreShadow;
float sky=wave*.64+.36*noise2(flow*vec2(8.,17.));
liquid+=vec3(.15,.21,.20)*smoothstep(.31,.72,sky);
liquid+=vec3(.13,.18,.16)*smoothstep(.54,.74,wave)*smoothstep(.25,.97,ripple);
c=mix(c,liquid,water);
return c;
}
void main(){
vec2 p=viewport(), offset=pixel()*vec2(.24,.17);
fragColor=vec4(.5*(shade(p-offset)+shade(p+offset)),1.);
}
`;
export function createGlacialMeltwaterChannelsMaterial(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 | glacial-meltwater-channels |
|---|---|
| Category | Water & Ice Shaders · Snow & Glacial Ice |
| Upstream study | ice/lib/11_meltwater_channels_incised_into_ice.glsl (commit c3a6f6c) |
| Animation cycle | Static analytical PBR surface |
| Declared uniforms | uResolution |
| Source size | 98 lines · 4.0 KB standalone GLSL ES 3.00 |
| PNG baker outputs | 512px · 1024px · 2048px RGBA8 (4-tap seamless + alpha key) |
| Companion pixel VFX | Free MIT ice sprite sheets |
| License | MIT License + CC0 / MIT Helpers |
Procedural signed-distance and analytic surface shading
David Hoskins, hash
AnimatedAnimated Rayleigh-instability liquid crown rim ejecting droplets over concentric pond ripples.
Animated19.47-degree Kelvin V-wake interference wave train trailing a moving watercraft.
AnimatedAdvancing and retreating beach wave sheet leaving wet darkened sand and lacy foam.
AnimatedFree-surface Rankine whirlpool depression with spiral capillary ridges and Fresnel sky reflection.
AnimatedMulti-directional Gerstner ocean wave spectrum with subsurface teal scatter and sun glitter.
AnimatedOverlapping circular capillary wave rings from stochastic raindrops hitting calm dark water.