Water ripples

Version 2 of 4

Touch the water.

Browser · canvas · 2010

This version

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.

How this version works

This 320-pixel-wide version uses the same two signed 16-bit height buffers, but removes the automatic stirrer and reduces the rain rate. Pointer movement adds a tapered disturbance of radius three, increasing to radius four with a stronger amplitude while pressed. The damped four-neighbour update spreads these disturbances through the interior, leaving the height-map boundary fixed. Local slopes distort the 512×256 tiled inlay and adjust its brightness, with ordinary RGB output instead of VGA quantisation.

The trick in this version

Canvas pointer coordinates are scaled from the displayed rectangle into the internal pixel grid. Events are reduced to one pending disturbance per rendered frame, and the touch setting leaves vertical swipes available for page scrolling.

Historical context · PC

  1. 2010 · Jonas Wagner

    HTML5 water ripples

    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.

  2. 2008 · Nikola · Microsoft developer blog

    Ripples in Silverlight

    Credits Elias and implements integer height buffers, damping and fast image generation inside a browser plug-in.

  3. 1999 · Alex Champandard · flipCode

    The flipCode water contest

    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.

Platform
Browser · canvas
Era
PC
Rendered on
CPU
Tags
interactive · wave equation
Sources
HTML5 water ripples (2010)Ripples in Silverlight (2008)The flipCode water contest (1999)