Refracting ripples
late '90sRain and a wandering stirrer disturb two integer buffers; the slopes bend a tiled floor with an inlay, quantised to the VGA's 18-bit colour.
next = (Σ neighbours) / 2 − previous
late '90s to today
Touch the screen and rings spread out, bounce off the edges and bend the tiles below, without a single sine. A filter over two arrays of numbers that seems to work like voodoo, as Hugo Elias put it, and nobody quite knows who found it first.
The algorithm
Keep two height maps: the current frame and the previous one. For every cell, the new height is half the sum of its four neighbours minus its own previous height, multiplied by a damping just below one. That small formula is a discrete wave equation, so ripples propagate, reflect off walls and interfere. To draw, offset each pixel's lookup into a background image by the local height slope, refraction, and brighten slopes that face the light.
The old-hardware trick
Integers, additions and a shift: the update needs no sines, no tables and no list of ripples, so a thousand drops cost the same as one. Swapping the two buffers instead of copying them halves the memory traffic.
damping = 0.97
for y, x in inner cells:
next[y][x] = ( cur[y][x−1] + cur[y][x+1]
+ cur[y−1][x] + cur[y+1][x] ) / 2
− next[y][x] // previous frame
next[y][x] ·= damping
swap(cur, next)
dx = cur[y][x−1] − cur[y][x+1]
pixel = floor_image[y + dy/8][x + dx/8] · (1 + dx·k)Documented milestones, with a source for each. Famous examples, not claims of who did it first.
Hugo Elias · CPU tutorial
Elias explains a ripple program he had seen with its source included, two integer arrays and a filter, inventor unknown. A reader later recalled finding the page around 1998.
SourceAlex Champandard · flipCode · PC · 3D hardware
A contest entry already calls the blur-sharpen filter ‘famous’, and picks a sum of sines instead because the filter's result depends on frame rate.
SourceNikola · Microsoft developer blog · Silverlight
Credits Elias and implements integer height buffers, damping and fast image generation inside a browser plug-in.
SourceJonas Wagner · Browser · HTML5 canvas
Inspired by a mr.doob wave-propagation demo: a pond in plain JavaScript that ripples under the mouse, refracted by offsetting texture lookups by the height difference.
SourceEvan Wallace · Browser · WebGL
A GPU height-field simulation you draw on, with a draggable sphere, raytraced reflections and refractions, soft shadows and caustics, on floating-point textures.
Source4 live versions, from the oldest platform to today: 2 on the CPU, 2 on the GPU. Retro versions run at their original resolution and palette. Demos pause when off screen.
Rain and a wandering stirrer disturb two integer buffers; the slopes bend a tiled floor with an inlay, quantised to the VGA's 18-bit colour.
The same simulation, now yours: move the pointer or swipe a finger sideways across the pool and watch the rings reflect off the edges and cross each other.
Champandard's alternative: a sum of decaying ring waves, frame-rate independent, evaluated per pixel with refraction, Fresnel and a sun glint.
Light bent by the moving surface bunches up into bright, shifting patches on the pool floor: where neighbouring refracted rays converge, the floor glows.