Skip to content
animorio
IT
Back to the library

Lighthouse background

Backgrounds, WebGLWebGL, GSAP, CSS onlyAdvancedCompressed weight: Demo 13 KBGSAP 28 KBFreeDownload the zip

A WebGL animated background for the hero of a small clifftop hotel, made only of light, fog and water, like a long-exposure night photograph: the lighthouse stays out of frame and its two beams turn slowly, coming in from far away narrow toward the horizon, crossing the sky, rising wide as they turn toward us and lighting up the fog with a flare when they look straight at us. The fog drifts in three layers and the beam only shows where it meets it; the dark water mirrors it, broken into glints, a fine drizzle appears only against the light, and a fine grain covers everything. No drawn shapes. The pointer moves the fog a little; pressing Book a sea room gives a double flash from the lamp and parts the fog.

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>
<!--
  "Lighthouse 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>Carrow Point</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/opsz.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/opsz-italic.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 hero of a small hotel on the cliff, at night. A WebGL shader draws only light, fog and water, like a long
       exposure: the beam of a lighthouse that stands just out of frame turns slowly and sweeps through the sea fog,
       the fog drifting in layers, the beam mirrored and broken on the dark water, a fine drizzle caught against the
       light, and grain. No drawn lighthouse: only its light. The pointer pushes the fog a little -->
  <section class="stage" data-stage>
    <canvas class="sea" aria-hidden="true" data-canvas></canvas>
    <div class="fallback" aria-hidden="true"></div>

    <header class="bar" data-in>
      <span class="brand">
        <svg class="brand__mark" viewBox="0 0 24 24" aria-hidden="true">
          <path d="M12 5.2v13.6"/><path d="M12 8.4L3.6 5.6" opacity=".55"/><path d="M12 8.4l8.4-2.8" opacity=".55"/><path d="M5 18.8h14"/>
        </svg>
        Carrow Point
      </span>
      <nav class="nav">
        <a class="nav__link nav__link--wide" href="#">Rooms</a>
        <a class="nav__link nav__link--wide" href="#">The bay</a>
        <a class="nav__link nav__link--pill" href="#">Stay the night</a>
      </nav>
    </header>

    <div class="hero">
      <a class="chip" href="#" data-in>
        <span class="chip__new">Winter</span>
        <span class="chip__words">Storm-watch weekends</span>
        <svg class="chip__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 4l4 4-4 4"/></svg>
      </a>
      <h1 class="title" data-title><span class="title__line">Sleep where the light</span> <span class="title__line">turns over the sea.</span></h1>
      <p class="lede" data-in>Eleven rooms on the cliff above the bay, a fire in the reading room and nothing but the sea between you and the dark.</p>
      <div class="actions" data-in>
        <button class="btn" type="button" data-btn data-autoclic>
          <span class="btn__face" data-face>
            <span class="btn__shine" aria-hidden="true"></span>
            <span class="btn__words" data-words>Book a sea room</span>
            <svg class="btn__icon" viewBox="0 0 16 16" aria-hidden="true">
              <path class="btn__arrow" data-arrow d="M3 8h9M8.5 4.2L12.3 8 8.5 11.8"/>
              <path class="btn__check" data-check pathLength="1" stroke-dasharray="1" stroke-dashoffset="1" d="M3.4 8.4l3 3 6.2-6.6"/>
            </svg>
          </span>
        </button>
        <a class="ghost" href="#">See the rooms</a>
      </div>
      <p class="note" data-in>
        <svg class="note__beam" viewBox="0 0 22 12" aria-hidden="true"><path class="note__ray" data-ray d="M11 6L1.5 2.6M11 6L1.5 9.4"/><path d="M11 6h9.5" opacity=".35"/></svg>
        <span data-note>The light sweeps the bay every ten seconds</span>
      </p>
    </div>

    <p class="hint" data-in>Move the pointer through the fog</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.

35 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 “Lighthouse 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

On an almost black night the hero of Carrow Point appears, an invented small hotel on the cliff above a bay: at the top the name with its lantern mark, ‘Rooms’, ‘The bay’ and the ‘Stay the night’ pill; at the bottom left, over the dark water, the ‘Winter, Storm-watch weekends’ label, the heading ‘Sleep where the light turns over the sea.’ with its second line in italics, a line about the eleven rooms on the cliff and the fire in the reading room, the lamp-coloured ‘Book a sea room’ button, ‘See the rooms’ and the note with two thin rays, ‘The light sweeps the bay every ten seconds’. Under the words there is only light, fog and water, as in a long-exposure night photograph. The lighthouse stands just out of frame on the right and never shows: you see its two beams, turning slowly, one turn every twenty seconds. Each one comes in from far away, narrow, pointing at the horizon where it ends; then it rises and crosses the whole sky; turning toward us it widens and climbs, and when it looks straight at us it lights up the fog and the water on the right with a warm flare. The fog drifts in three layers at three speeds: a thick bank lying on the sea, a middle layer, thin wisps up high; the beam only shows where it meets it, broken and brighter where it is thicker. A thin mist lies right on the horizon. The dark water mirrors the beam upside down, broken by ripples that get finer toward the horizon, with glints where the waves catch the light. A fine drizzle falls at a slant like the streaks of a long exposure and only shows against the light, inside the beam. The heading warms a little when a beam passes over it. On its own, a push crosses the fog from left to right, then the button is pressed: it gives and comes back on a spring, a band of light slides over it, the lamp gives a double flash, the fog parts and runs faster, the label turns into ‘Sea room held’ with a checkmark that draws itself, the two rays of the note open and the note says ‘Room seven, the lamp side, two nights’; then everything goes back. With the pointer the fog moves aside where it passes and is dragged in the direction of the gesture.

How it works

Everything is a shader

The background is a WebGL shader on a single triangle covering the canvas, under the words: sky, beams, fog, water, drizzle and grain. No images and no shapes, the lighthouse is never drawn. The canvas is drawn at a density that keeps it under half a million pixels, because the fog is soft; without WebGL a CSS gradient of the same night remains.

The beam in perspective

The lighthouse stands out of frame on the right and each beam has an angle around the tower. On screen the beam heads for the point of the horizon where its direction vanishes: going away it narrows and ends there, sideways it crosses the whole sky, coming toward us it rises and widens. One vector is enough, focal length times cosine plus the offset of the tower times sine, with no divisions that blow up.

The light lives in the fog

Three four-octave fbm noises, stretched horizontally and held in Gaussian bands, drift at three speeds: the bank on the sea, the middle layer, the high wisps. The beam is multiplied by the density of the fog, so in clear air it almost vanishes and where the fog is thick it lights up in patches. When a beam looks straight at us, the dot product of its direction and the camera's to the sixteenth power makes the flare.

The water and the drizzle

Below the horizon the shader asks for the light of the beam at the mirrored point, moved by ripples that tighten toward the line, and two multiplied noises make the glints where the reflected light is strong. The drizzle is two grids of slanted cells falling at different speeds: a few cells hold a thin streak, multiplied by the light of the beam, so it only shows against the light.

The push of the pointer and the heading that warms

The pointer is a Gaussian circle that shifts the coordinates the fog is read at and drags it with the speed of the gesture; when nobody touches, a push from the automatic loop takes the same path. The same beam, rewritten in JavaScript, measures how much light falls on the heading and hands it to the CSS as --lit: the colour and halo of the heading warm on a spring when a beam passes over it.

Values to change

NameFileDefaultWhat it changes
TURNscript.js20Seconds for one full turn of the lamp (two beams: a sweep every half turn).
BEAMscript.js1How bright the beams are.
WIDTHscript.js1How wide the beams are.
FOGscript.js1How thick the fog is (0 = clear air, the beams almost vanish).
DRIFTscript.js1How fast the layers of fog drift.
RAINscript.js1How much drizzle shows against the light (0 = none).
RIPPLEscript.js1How much the water breaks the reflection.
PUSHscript.js1How far the pointer pushes the fog.
GRAINscript.js0.04How strong the grain is.
SPEEDscript.js12 = the loop on its own and the lamp twice as fast, 0.5 = half.
LOOPscript.jstrueRepeats the loop of the push and the button.

Try them in the Playground

When to use it

As the background of the first screen of a seaside hotel or holiday home, a ferry company, a harbour restaurant, a winter festival on the coast, a weather or sailing app: wherever a slow night and a passing light are wanted instead of a photo. The colours are --night, --haze, --fog, --beam, --amber and --sea in the CSS.

On phones

The same animations at adapted sizes: on narrow screens the horizon rises to the middle, the lighthouse moves a little further from the edge so the flare does not cover the heading, the heading is measured on width and height, the two buttons stay on one row, the Rooms and The bay links go, and on short screens the note and the line at the bottom too. With a finger the fog follows the gesture.

With reduced motion

The beam stays still across the sky, the fog and the water are still and there is no drizzle; everything fades in. Pressing the button the fog thins without moving and the label, the checkmark and the note change without motion.

Pitfalls

  • A drawn lighthouse, even just the tower against the light, turns it into an illustration at once: here it stays out of frame and only its light shows, so it reads as a photograph.
  • A beam that only rotates like a flat fan looks like a disco light: a real beam heads for its vanishing point on the horizon, narrowing as it goes away and widening as it comes toward us.
  • A beam drawn the same everywhere looks like a cut of light on the screen: multiplied by the density of the fog it becomes light in the air, in patches, and almost vanishes in clear air.
  • In software WebGL a big canvas stalls the page: the density is chosen to stay under half a million pixels and drops on its own if frames are slow.

Libraries

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

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

Testing

Tested on 4 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