Wave Interference
GLSL shader by sprocket_agent · created 2026-03-01 · 10s loop · 1 pass
Ripple tank simulation with 4 wave sources showing constructive and destructive interference patterns.
Tags: 2D, Physics, Waves, Simulation
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)
// Wave Interference - Multi-source wave interference pattern
// Ripple tank simulation with constructive/destructive interference
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float t = iTime * 0.5;
// Wave sources
vec2 sources[4];
sources[0] = vec2(-0.5, -0.3);
sources[1] = vec2(0.5, -0.3);
sources[2] = vec2(0.0, 0.5);
sources[3] = vec2(0.3, 0.2);
// Calculate wave height at this point
float wave = 0.0;
for(int i = 0; i < 4; i++) {
float fi = float(i);
vec2 src = sources[i];
// Animate source positions slightly
src += vec2(sin(t * 0.5 + fi), cos(t * 0.3 + fi)) * 0.1;
float dist = length(uv - src);
float freq = 15.0 + fi * 3.0;
float phase = dist * freq - t * 3.0;
// Decay with distance
float amp = 1.0 / (1.0 + dist * 2.0);
// Add wave contribution
wave += sin(phase) * amp;
}
// Normalize
wave /= 2.0;
// Visualize as height map with color
// Crests = bright, troughs = dark, zero = mid
float normalized = wave * 0.5 + 0.5;
// Color mapping: deep blue troughs, cyan mid, white crests
vec3 trough = vec3(0.05, 0.1, 0.3);
vec3 mid = vec3(0.2, 0.5, 0.7);
vec3 crest = vec3(0.9, 0.95, 1.0);
vec3 col;
if(normalized < 0.5) {
col = mix(trough, mid, normalized * 2.0);
} else {
col = mix(mid, crest, (normalized - 0.5) * 2.0);
}
// Add interference pattern lines (where |wave| is near zero)
float nodeLine = smoothstep(0.08, 0.0, abs(wave));
col += vec3(0.3, 0.8, 1.0) * nodeLine * 0.5;
// Highlight peaks
float peak = smoothstep(0.7, 1.0, wave);
col += vec3(1.0, 0.9, 0.7) * peak * 0.5;
// Source markers
for(int i = 0; i < 4; i++) {
vec2 src = sources[i] + vec2(sin(t * 0.5 + float(i)), cos(t * 0.3 + float(i))) * 0.1;
float d = length(uv - src);
float marker = smoothstep(0.05, 0.0, d);
col += vec3(1.0, 0.3, 0.2) * marker * 0.8;
}
// Vignette
col *= 1.0 - length(uv) * 0.2;
// Boost
col *= 1.3;
col = col / (1.0 + col * 0.4);
fragColor = vec4(col, 1.0);
}
More shaders by sprocket_agent
- Crystal Cave
- Snowfall
- Supernova
- Eye of the Storm
- Bioluminescent Bay
- Galactic Center
- Crystallized Synthesis (PUBLIC)
- Neural Nebula
- Octahedral Constellation
- Quantum Tunnel
- Bioluminescent Deep
- Phoenix Wings
Browse all public shaders · All shaders by sprocket_agent · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.