Waves on waves
GLSL shader by scry · created 2026-02-05 · 10s loop · 2 passes
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. //1 degree
#define time iTime*2.*pi/10. //sin(time) loops 10 seconds
#define R iResolution.xy //shorthand
#define ar R.x/R.y //aspect ratio
#define M iMouse //shorthand
#define xm (M.xy/R) //normalized mouse
#define nm ((xm.xy-0.5)*vec2(ar,1.)+0.5) //aspect ratio correction
vec3 cs = vec3(1.,2.,3.);
mat2 r2d(float a) {
return mat2(cos(a),sin(a),-sin(a),cos(a));
}
// HSV to RGB
vec3 hsv2rgb(vec3 c) {
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
// RGB to HSV
vec3 rgb2hsv(vec3 c) {
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
float d = q.x - min(q.w, q.y);
float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
Buffer A (iChannel0)
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord.xy / iResolution.xy;
// Initialize with random blobs on first frame or mouse click
if (iFrame < 2 || iMouse.z > 0.5) {
vec2 p = fragCoord / iResolution.y;
float n = 0.0;
for (int i = 0; i < 5; i++) {
vec2 center = vec2(fract(sin(float(i) * 12.9898) * 43758.5453),
fract(sin(float(i) * 78.233) * 43758.5453));
n += exp(-length(p - center) * 8.0);
}
float val = clamp(n * 0.6, n*0.5, n*0.4);
fragColor = vec4(val * fract(sin(float(1) * 11.1998) * 43758.5453),
val * fract(sin(float(1) * 12.9898) * 43758.5453),
val * fract(sin(float(1) * 1.5) * 43758.5453),
1.0);
return;
}
// Lenia-style continuous cellular automata
vec2 px = 1.0 / iResolution.xy;
// Kernel radius and growth function parameters
vec3 cell = texture(iChannel0, uv).rgb;
float Rr = 19.0-sin(cell.b+cell.g+cell.r)*5.5;
float mu = 0.31+cell.r*0.3;
float sigma = 0.20-cell.g*0.20;
// Compute weighted neighborhood sum with Gaussian kernel
vec3 sum = vec3(0.0);
vec3 totalWeight = vec3(0.0);
for (float dy = -Rr; dy <= Rr; dy += 1.0) {
for (float dx = -Rr; dx <= Rr; dx += 1.0) {
float dist = length(vec2(dx, dy));
if (dist > Rr) continue;
// Ring kernel (shell-like)
float kernelDist = abs(dist / Rr - 0.5) * 2.0;
float weight = exp(-kernelDist * kernelDist / 0.15);
vec3 neighbor = texture(iChannel0, uv + vec2(dx, dy) * px).rgb;
// Red channel uses standard weight
sum.r += neighbor.r * weight;
totalWeight.r += weight;
// Green and blue channels modulated by red
float redModulation = cell.r;
sum.g += neighbor.g * weight + neighbor.b * weight * redModulation * 0.1;
sum.b += neighbor.b * weight + neighbor.g * weight * redModulation * 0.1;
totalWeight.g += weight;
totalWeight.b += weight;
}
}
vec3 U = sum / totalWeight;
// Red channel subtly influenced by blue and green
float growthR = exp(-pow(U.r - mu, 2.0) / (2.0 * sigma * sigma)) * 2.0 - 1.0;
growthR += (U.g + U.b - 2.0 * mu) * 0.02;
vec3 growth = vec3(growthR, exp(-pow(U.g - mu, 2.0) / (2.0 * sigma * sigma)) * 2.0 - 1.0, exp(-pow(U.b - mu, 2.0) / (2.0 * sigma * sigma)) * 2.0 - 1.0);
vec3 newState = clamp(cell + growth * 0.1, 0.0, 1.0);
newState = mix(newState,texture(iChannel0,uv).rgb,0.2);
fragColor = vec4(newState, 1.0);
}
Image
Not used
More shaders by scry
- Project_2026-08-15_18-22-06
- Project_2026-08-14_16-45-00
- Project_2026-07-24_15-10-23
- Project_2026-07-15_03-18-26
- Glass of Orange Juice (raymarched)
- Project_2026-07-13_00-53-50
- Project_2026-07-10_16-39-54
- Popcorn ceiling
- Project_2026-06-20_15-32-19
- Project_2026-06-25_12-22-43
- Visual Enhancer
- Project_2026-06-24_11-11-39
Browse all public shaders · All shaders by scry · ShaderKit home
Unread comments
×Projects with new comments. Click to open and read.