Skip to content
animorio
IT
Back to the library

Pool caustics background

Backgrounds, WebGL, HoverWebGL, GSAPAdvancedCompressed weight: Demo 10.0 KBGSAP 28 KBFreeDownload the zip

A hand-written WebGL animated background for the opening of a made-up thermal spa, Saltwell, seen from above the pool: on the floor a pale mosaic of glazed tiles, its grout lines bent by the surface, and on it the net of caustic light the water focuses down, sharp where it folds, with a thread of red outside and blue inside its edges, like light split by water. The surface is the sum of twelve slow waves and the light is worked out from how much each patch of water squeezes the sun. The pointer is a finger in the water: it dents the surface under it and leaves rings that spread and fade.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Pool caustics background" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Saltwell Baths</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz-italic.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the opening of a made-up thermal spa, seen from above the pool: a WebGL shader draws the pale mosaic on the
       floor of the basin and the net of caustics the surface throws on it, with a thread of colour on the edges of
       the light. The pointer is a finger in the water: it dents the surface and leaves rings that spread and fade -->
  <section class="stage" data-stage>
    <canvas class="pool" aria-hidden="true" data-canvas></canvas>
    <div class="glow" aria-hidden="true"></div>

    <header class="bar" data-in>
      <span class="brand">
        <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true">
          <rect x="3.5" y="3.5" width="17" height="17" rx="2.5"/>
          <path d="M3.5 12h17M12 3.5v17" class="brand__grout"/>
          <path class="brand__wave" data-wave d="M6.2 15.6c1.9-1.3 3.8-1.3 5.8 0s3.9 1.3 5.8 0"/>
        </svg>
        Saltwell
      </span>
      <a class="book" href="#" data-book data-autoclic>
        <span class="book__face">
          <span class="book__words">Book a soak</span>
          <svg class="book__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M3.5 8h8.5M8.8 4.6L12.2 8l-3.4 3.4"/></svg>
        </span>
      </a>
    </header>

    <div class="hero">
      <p class="eyebrow" data-in>Thermal baths, open daily from seven</p>
      <h1 class="title" data-title>
        <span class="title__line">Light, slowed</span>
        <span class="title__line">by <em>warm</em> water.</span>
      </h1>
    </div>

    <p class="temp" data-in>
      <span class="temp__label">Main pool</span>
      <span class="temp__value"><span data-temp>34.0</span> &deg;C</span>
    </p>
    <p class="sr" aria-live="polite" data-live></p>
  </section>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

29 values to change

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Pool caustics background” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

The screen is the floor of a pool seen from above: square bone-coloured tiles, each a little different and slightly domed, with thin grey-green grout, all veiled by the aqua of the water and a little darker towards the corners. Over the tiles the caustic net moves slowly: lines of light that tighten, knot and loosen, brighter at the knots, with a pinkish thread on the outer side and a blue one on the inner side; the grout lines sway gently because they are seen through the water. At the top the Saltwell mark with a tile drawn in a line whose little wave rocks half a pixel with the water, and the Book a soak button; in the middle the line «Thermal baths, open daily from seven» and the heading «Light, slowed by warm water.» in Newsreader, with «warm» in deep aqua italic, and its soft shadow on the floor swaying with the water. At the bottom left the reading Main pool 34.0 °C. Moving the pointer the surface dents under it like under a finger, and the light there gathers into a lens; every so often a ring spreads out, bends the net and the grout and fades. Pressing drops a stronger ring. Book a soak squashes and springs back, sends two rings out from the button, the light of the pool rises for a moment and the temperature goes up by a tenth, then back. Left alone, a finger crosses the water under the heading, then taps once on the right and presses the button.

How it works

The surface as a sum of waves

In the fragment shader the surface is the sum of twelve waves in directions spread by the golden angle, from a tenth to a third of the screen long. Each moves at the speed of deep water, its frequency growing with the square root of the wavenumber: short waves are slower than you would think, and the net moves like real water. For each wave the slope and the curvature are added up, written by hand: no textures, no numerical derivatives.

Light from curvature

A ray of sun going through the surface bends as much as the water is tilted, and a small patch of surface reaches the floor wider or narrower depending on the curvature: the light is the inverse of the determinant of I + D·H, with D the depth and H the curvature. Where the determinant goes through zero the light folds onto itself and the sharp line of the caustics appears; a floor at 0.055 avoids infinity and a soft shoulder keeps the knots bright without burning out the tiles.

The thread of colour on the edges

The same formula is worked out three times at three slightly different depths, one for red, one for green, one for blue (SPLIT, 5% by default): red folds a little further than blue, and each line gets a pinkish thread outside and a blue one inside, like the real dispersion of water. It costs little because the curvature is computed only once.

The mosaic seen through the water

The tiles are drawn in the shader at the point shifted by the slope of the surface, so the grout lines sway. Each tile has a tone from a hash of its cell and a dome that darkens it towards the edges; the aqua veils it a little more towards the corners, then vignette and grain.

The finger and the rings

The pointer is a Gaussian dent in the surface that follows it with a soft lag and sinks deeper the faster it moves: the light gathers there as under a lens. Every so often, once it has moved far enough, a ring sets off: a short train of waves on a running front that widens and fades, with slope and curvature computed in radial coordinates. Eight rings at most, the oldest makes room.

The button, the autopilot and the fallback

Book a soak squashes and springs back on an elastic ease, sends two rings out from its centre, lifts the light and warms the temperature by a tenth for three seconds. Left alone, a GSAP timeline draws a finger under the heading, taps on the right and presses; at the first real movement it stops and starts again three seconds later. Without WebGL a CSS mosaic with two patches of light remains.

Values to change

NameFileDefaultWhat it changes
DRIFTscript.js1How fast the water moves (0 = still).
LIGHTscript.js1How bright the caustics are.
DEPTHscript.js1How deep the pool is: deeper folds the light into finer, sharper lines.
SIZEscript.js1Size of the waves and of the cells of light.
SPLITscript.js0.05How much the water splits the light into colour on the edges (0 = white).
TILEscript.js0.06Size of the tiles, as a share of the screen.
RIPPLEscript.js1Strength of the rings, from the pointer and the button.
FINGERscript.js1How deep the finger dents the surface under the pointer.
GRAINscript.js0.025Strength of the grain.
SPEEDscript.js1Speed of the walk on its own: 2 twice as fast, 0.5 half.
LOOPscript.jstrueThe walk on its own starts again every time.

Try them in the Playground

When to use it

As the background of the first screen of a spa, thermal baths, a hotel or a holiday home with a pool, a pool builder, a swimwear or sunscreen brand, a wellness centre or a swimming app: wherever a lively, calm light is wanted instead of a gradient. The colours are --tile, --grout, --water, --light and --accent in the CSS.

On phones

The same animations at adapted sizes: waves and tiles are measured on width and height, so a phone sees cells of light like a large screen, and the heading is measured on the height too. With a finger you touch the water: the dent follows the finger and the rings appear.

With reduced motion

The water stays still, no dent and no rings: the light and the caustics fade in; pressing the button the light brightens slightly and the temperature changes without motion.

Pitfalls

  • The inverse of the determinant goes to infinity right on the lines: without a floor (0.055 here) and a soft shoulder the lines become flickering white pixels.
  • The light is computed at the point of the surface, not at the point of the floor where it lands: it is an approximation, and holds only while the pool is shallow compared to the waves. With DEPTH too high the lines double into odd folds.
  • The derivatives of the spreading ring in radial coordinates contain h’/r, which grows huge near the centre: the radius has a minimum and the front starts already at a distance, so there is no white dot in the middle.
  • With all waves at the same speed the net slides like a dragged drawing: with the speed of deep water (square root of the wavenumber) each scale moves on its own, like real water.
  • Dispersion has to be done on the depth, not by shifting the three channels by a few pixels: with a shift the colour is the same in every direction and looks like a misprint.

Libraries

GSAP 3.15.0, Newsreader (font variabile) 5.3.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 10.0 KB; the libraries: GSAP 28 KB.

Testing

Tested on 11 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations