Skip to content
animorio
IT
Back to the library

Fogged glass

Backgrounds, WebGL, HoverGSAP, WebGL, Canvas, CSS onlyAdvancedCompressed weight: Demo 11 KBGSAP 28 KBFreeDownload the zip

An animated background for an AI app’s hero, at night: behind the headline a window pane fogged with breath, and behind the glass the lights of a city out of focus. The pointer wipes the condensation like a hand: the lights come through sharp, the edge of the wiped trail catches the light, a few drops run down in spurts and slowly the glass fogs up again in patches. The button clears the whole pane with one wave. A hand-written WebGL shader, in the Libraries.dev style.

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>
<!--
  "Fogged glass" 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>The fogged glass background you wipe clear with the pointer</title>
  <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 an invented AI assistant, Clearly, at night: behind the words a window pane fogged with breath, and
       behind the glass the lights of a city out of focus; the pointer wipes the fog away like a hand, the lights come
       through sharp, a few drops run down the clear trail, and slowly the fog comes back -->
  <main class="stage" data-stage>
    <canvas class="glass" data-glass aria-hidden="true"></canvas>
    <canvas class="fog-flat" data-fog-flat aria-hidden="true"></canvas>
    <span class="grain" aria-hidden="true"></span>

    <section class="hero" aria-labelledby="hero-title">
      <p class="pill" data-in>
        <span class="pill__tag">New</span>
        <span class="pill__text">Clearly 2 sorts your week in one pass</span>
        <svg class="pill__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M6 3.5 10.5 8 6 12.5"></path></svg>
      </p>
      <h1 class="title" id="hero-title" data-in data-title>See through<br>the noise</h1>
      <p class="lede" data-in>Mail, meetings and notes, cleared into one calm plan. Ask Clearly what matters today.</p>
      <div class="actions" data-in>
        <button class="cta" type="button" data-cta>
          <span class="cta__label">Try it free</span>
          <svg class="cta__arrow" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h9.5M8.5 4 12.5 8l-4 4"></path></svg>
        </button>
        <span class="hint" data-hint>
          <svg class="hint__hand" viewBox="0 0 20 20" aria-hidden="true"><path d="M3 10.5c2.2-1.6 4-1.6 6 0s3.8 1.6 6 0"></path><path d="M3 14.5c2.2-1.6 4-1.6 6 0s3.8 1.6 6 0"></path></svg>
          <span>Wipe the glass</span>
        </span>
      </div>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 20 20" aria-hidden="true"><path d="M4 2.5v13.2l3.5-3.3 2.4 5.3 2.3-1-2.4-5.2 4.8-.2z"></path></svg>
  </main>

  <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.

23 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 “Fogged glass” 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 first screen of an invented AI assistant, Clearly, at night: a pill «New · Clearly 2 sorts your week in one pass», the big two-line headline «See through the noise», a lighter line of text, the button «Try it free» and beside it, small, «Wipe the glass». Behind it there is a window pane fogged with breath, and behind the glass the lights of a city out of focus: orange like street lamps and windows, a few cold ones, each trembling a little on its own. Through the condensation the lights are wide milky patches and the black is a glassy grey, with a fine grain of tiny beads. The pointer moves over the glass like a hand and wipes the condensation away: there the lights come through sharp, with their discs and a brighter rim, and along the edge of the wiped trail a thread of water catches the light, with a darker line just inside. Now and then a drop breaks off the wiped area: it runs down in spurts, stops, starts again and leaves a clean streak behind it; inside the drop the city is upside down, with a point of light at the top. Slowly the glass fogs up again, in patches, and the pane breathes. The more glass is clear, the more the headline widens a little and takes on a warm light. The button, when pressed, squashes and springs back and clears the whole pane with a wave starting from it, like a squeegee going round, dropping a few drops. If nobody moves the pointer, a drawn one wipes the glass back and forth, waits for it to fog up and presses the button.

How it works

One triangle covering the page

The WebGL canvas draws a single triangle bigger than the screen, and all the work is in the fragment shader: for each pixel it works out the city seen through clear glass and the city seen through the condensation, and mixes them by how much fog there is at that point.

The city behind the glass

Eighteen fixed lights, picked with a seeded generator, most of them low like streets and windows. Through clear glass each one is a disc with a brighter rim; through the fog it becomes a bell BLUR times wider, washed towards grey, and the black rises to a glassy grey.

The fog is a small canvas

The condensation lives in a 2D canvas a quarter the size of the page, white with alpha: the hand punches it with soft destination-out stamps, close together along the stroke. Every frame the canvas becomes the shader’s texture.

The glass fogging up again

Every frame a patchy white drawing is laid over the canvas, very transparent: the fog comes back faster in some places, so the glass fogs up again in blotches, in FOG_BACK seconds.

The water edge and the drops

The shader measures how much the fog changes around the pixel: where it changes a lot is the edge of the wiped trail, and there it adds a thread of light and a darker line. The drops are a JavaScript list: they run down in spurts, clear a thin streak and in the shader they are small lenses showing the city upside down.

The button and the drawn pointer

When pressed, the button starts a wave: a ring of stamps growing from the button to the corners in 1.5 seconds. The headline reads how much glass is clear and widens a little. After a few seconds without a pointer a looping timeline with a drawn pointer starts; the first real movement stops it.

Values to change

NameFileDefaultWhat it changes
FOG_BACKscript.js8How many seconds the wiped glass takes to fog up again.
WIPEscript.js44Radius of the wiping hand, in pixels.
DRIPSscript.js1How many drops run down from the wiped area (0 none).
LIGHTSscript.js1How strong the lights behind the glass are.
BLURscript.js1How much the condensation spreads and blurs the lights.
AUTO_PILOTscript.js3After how many seconds without a pointer the drawn one starts wiping (0 never).

Try them in the Playground

When to use it

For the hero of an AI app, a service that tidies things up, a hotel or a bar at night: when you need a dark background that invites a touch and still leaves the headline in front.

On phones

Same animations: the finger wipes the glass (the page doesn’t scroll over the demo), the lights are sized on the short side of the screen and the text fits inside the box.

With reduced motion

With reduced motion the glass is already fogged with one clear band behind the headline, still: no drops, no trembling lights, no fogging up again; you can still wipe with the pointer, and the words only fade in.

Pitfalls

  • The fog texture must be uploaded with UNPACK_FLIP_Y: the canvas starts from the top, gl_FragCoord from the bottom.
  • Redrawing the fog on every resize loses what was wiped: the old canvas has to be stretched into the new one.
  • Fog coming back evenly looks like a fade: laid through a patchy drawing it returns like on a real window.
  • Without WebGL the CSS background with the lights stays, with the fog canvas blurred on top: it still wipes.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 30 October 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