GLSL Learning

GLSL shader example

Water Ripple

Expanding water ripples from the center: a sine wave over distance, moving with time and fading with exp().

Live example

Edit the code and the preview updates as you type.

How it works

sin(d * 25.0) with d being the distance from the center gives rings: every point at the same distance gets the same value. 25.0 controls how close together the rings are.

Subtracting u_time * 4.0 inside the sine shifts the wave over time. Since the pattern repeats along distance, the shift looks like the rings traveling outward.

Two more pieces make it read as water:

  • exp(-d * 2.0) is 100% at the center and drops off smoothly with distance, so the waves weaken as they spread, like real ripples.
  • pow(0.5 + 0.5 * wave, 6.0) keeps only the very top of each wave. Raising a 0..1 value to a high power pushes most values toward 0 and leaves just the peaks bright, which become thin glinting crests.

Try changing it

ChangeResult
25.0 to 60.0Many tight ripples
- u_time * 4.0 to + u_time * 4.0Rings travel inward
exp(-d * 2.0) to 1.0Ripples never fade
length(p) to length(p - vec2(0.5, 0.3))The drop lands off-center

Built-in functions used

Learn it step by step