Skip to content
animorio
IT
Back to the library

Two glass lenses background

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

The first screen of Aurel Biologics, a made-up biotech company. Behind the title a WebGL2 shader written by hand: a vertical gradient of five colours mixed in OKLab that slides slowly back and forth, and over it two big glass lenses, one hanging from the top and one rising from the bottom. They bend the light with a thin rainbow on the rim, and the second bends the picture already bent by the first: where they touch they deform each other. They follow the pointer a little on a spring and catch a thin highlight top left; the title rises line by line from behind a mask and the round arrow button answers the pointer.

Rebuilt from scratch studying polpharmabiologics.com by Widelab: the idea is theirs; code, copy and images are ours. Read how it’s made

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>
<!--
  "Two glass lenses 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>The background with the two glass lenses on the lab gradient</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/fraunces@5.3.0/full.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 first screen of Aurel Biologics, a made-up biotech company. Behind the words a hand written WebGL2 shader
       draws a slow vertical gradient mixed in OKLab and two big glass lenses over it: one hangs from the top, one
       rises from the bottom, and the second refracts the picture already bent by the first. They follow the pointer
       a little on a spring and lean into each other where they touch -->
  <main class="hero" data-hero>
    <div class="hero__bg" data-bg aria-hidden="true">
      <canvas class="hero__gl" data-gl></canvas>
      <!-- without WebGL2: the same gradient in CSS (in oklab) and two lenses made of borders and soft light -->
      <div class="hero__css" data-css>
        <span class="lens lens--top"></span>
        <span class="lens lens--bottom"></span>
      </div>
    </div>

    <header class="bar" data-bar>
      <a class="brand" href="#" aria-label="Aurel Biologics">
        <svg class="brand__mark" viewBox="0 0 28 28" aria-hidden="true">
          <circle class="brand__ring" cx="14" cy="9.2" r="8.4"/>
          <circle class="brand__ring" cx="14" cy="19.6" r="7.4"/>
          <path class="brand__drop" d="M7.9 15.1a8.4 8.4 0 0 0 12.2 0a7.4 7.4 0 0 0-12.2 0Z"/>
        </svg>
        <span class="brand__words"><b>Aurel</b><small>Biologics</small></span>
      </a>
      <nav class="nav" data-nav aria-label="Main">
        <span class="nav__glow" data-glow aria-hidden="true"></span>
        <a class="nav__link" href="#">Science</a>
        <a class="nav__link" href="#">Pipeline</a>
        <a class="nav__link" href="#">Partners</a>
        <a class="nav__link" href="#">Careers</a>
      </nav>
      <a class="contact" href="#" data-contact><span class="contact__body" aria-hidden="true"></span><span class="contact__say">Contact</span></a>
      <button class="menu" type="button" aria-label="Open the menu">
        <span class="menu__say">Menu</span>
        <svg viewBox="0 0 16 16" aria-hidden="true"><path d="M3 6h10M3 10h10"/></svg>
      </button>
    </header>

    <div class="copy">
      <h1 class="title" data-title>
        <span class="title__line"><span class="title__words">Every molecule,</span></span>
        <span class="title__line"><span class="title__words">measured twice.</span></span>
      </h1>
      <p class="sub" data-sub><span class="sub__words">Biosimilars engineered from cell line to commercial supply.</span></p>
    </div>

    <button class="more" type="button" data-more aria-label="Scroll to the next section">
      <span class="more__ripple" data-ripple aria-hidden="true"></span>
      <span class="more__body" data-more-body aria-hidden="true"></span>
      <span class="more__track" aria-hidden="true">
        <svg class="more__arrow" data-arrow viewBox="0 0 20 20"><path d="M10 3.5v12.2M4.9 10.6 10 15.7l5.1-5.1"/></svg>
        <svg class="more__arrow more__arrow--next" data-arrow-next viewBox="0 0 20 20"><path d="M10 3.5v12.2M4.9 10.6 10 15.7l5.1-5.1"/></svg>
      </span>
    </button>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 2.8v16.4l4.2-4 2.8 6.2 2.9-1.3-2.8-6.1h5.9Z"/></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.

38 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 “Two glass lenses 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 a background going from an almost black petrol green at the top to a bluish white at the bottom sit two big glass lenses: one hangs from the top and covers almost the whole width, the other rises from the bottom. Inside the lenses the gradient bends and grows, a thin line of red and blue appears on the rim, and where the two lenses overlap the rim of the top one, seen through the bottom one, curls like a drop. On top, the Aurel Biologics brand, the menu in a frosted glass pill with a light sliding under the link under the pointer and the coral Contact button; in the middle the title «Every molecule, measured twice.» in a serif with soft serifs and the line «Biosimilars engineered from cell line to commercial supply.»; at the bottom the round button with the arrow. On arrival the background settles from 1.15 to 1, the top lens comes down to its place in 2 seconds and the title rises one line at a time. The gradient slides very slowly, back and forth. Moving the pointer the lenses follow it a little, in opposite directions, on a spring that arrives and settles; where the rims cross they swell towards each other. Over the round button the arrow goes down and another one comes from the top, the glass swells and the bottom lens breathes; pressing the button squashes it, it comes back on an elastic and leaves a ring that grows. Left alone, a drawn mouse pointer moves the lenses, passes over the menu links and presses the button.

How it works

Three passes on two textures

One triangle covering the screen and three programs: the gradient is drawn into a texture, the top lens reads it and writes into a second one, the bottom lens reads the second and writes to the screen. So the second lens bends the picture already bent by the first, and that is what deforms the rims where they overlap. The canvas is at 1.5x at most, like the site's scene.

The gradient in OKLab

From the site: five vertical stops, #011919 at 0, #024546 at 0.19, #639EA5 at 0.52, #B1CBD4 at 0.70, #E7F0F7 at 1. Between two stops the colours go linear, then to LMS with the cube root, they mix and the chroma gets a small push with lms *= 1 + 0.025 · t · (1 - t). A pcg2d noise on gl_FragCoord adds or takes half a step of 8 bit, and the banding is gone.

Back and forth

From the site: the position is y minus time times 0.01; floor gives the cycle, and on even cycles it reads 1 - fract, on odd ones fract. The gradient never jumps: where the cycle changes it mirrors, and the lightest fold rises slowly from the bottom and then comes back. Here time is in seconds (the DRIFT knob).

The lens: a circle SDF

From the site: st = (uv - centre) · aspect / 1.7 (1.55 for the second), sd = length(st) - 0.4, offset = st / sd. Inside sd is negative, so it reads towards the centre and the picture grows; near the rim sd goes to zero and the offset explodes: that is the dark line on the rim. Red, green and blue are read with steps of 0.0088, 0.01 and 0.0112 for a strength of 0.4 (0.31 and a dispersion of 0.44 for the second): there is the rainbow. Alpha is smoothstep(0, 0.0025, -sd) and five samples 0.0005 apart are averaged.

Places, entrance and phone

From the site: the first lens sits at (0.5, 0.15) and the second at (0.5, 1.2), with its centre below the edge; between 576 and 991 px the second goes to x 1, under 576 px both go right, (1.55, 0.099) and (1.577, 1.149). The first comes in from y 0 in 2 s on easeInOutQuad (power1.inOut), the background from scale 1.15 to 1 in 2.5 s power3.out, and the title rises line by line from yPercent 110 in 0.8 s expo.out, 0.1 s apart, the line below 0.35 s later.

Ours: spring, embrace, highlight

The lenses follow the pointer by up to 0.04 screens, in opposite directions, on a spring just under critical damping (stiffness 70, damping 12.5) and breathe by a few thousandths. Where the two rims cross each distance loses 0.006 · exp(-(dA² + dB²) / 0.0016): the rims swell towards each other. A light line a couple of pixels wide runs inside the rim, stronger top left and weaker at the bottom; the button swells the bottom lens on a spring.

Values to change

NameFileDefaultWhat it changes
COLOR_TOPscript.js#011919The colour at the top of the gradient (the site's).
COLOR_PETROLscript.js#024546The second stop, at 19 %.
COLOR_SEAscript.js#639ea5The third stop, at 52 %.
COLOR_HAZEscript.js#b1cbd4The fourth stop, at 70 %.
COLOR_MISTscript.js#e7f0f7The colour at the bottom of the gradient.
DRIFTscript.js0.01How fast the gradient slides back and forth, per second (the site uses 0.01).
CHROMAscript.js0.025The chroma push of the OKLab mix (the site uses 0.025).
LENS_TOPscript.js1.7How big the top lens is (the site uses 1.7).
LENS_BOTTOMscript.js1.55How big the bottom lens is (the site uses 1.55).
BENDscript.js0.4How strongly the top lens bends the light (the site uses 0.4; the bottom lens takes 78 % of it).
DISPERSIONscript.js0.6The rainbow on the rim (the site uses 0.6 on top and 0.44 below).
ENTERscript.js2Seconds the top lens takes to come down (the site uses 2).
FOLLOWscript.js0.04How far the lenses follow the pointer, in screen heights (0 still).
TENSIONscript.js1How much the rims swell towards each other where they cross (0 not at all).
SHINEscript.js0.55The thin highlight top left on the rims (0 none).
AUTOPILOTscript.jstrueLeft alone, a drawn pointer moves the lenses, walks the menu and presses the button.

Try them in the Playground

When to use it

For the first screen of a site for biotech, pharma, labs, clinics, research or health, and of any product that wants to feel precise and calm: a fintech, an architecture studio, a wellness app, the page of a medical device. The lenses sit well behind a short title; the gradient changes with the five colours.

On phones

The same shader with the places of the site's phone scene: under 576 px the two lenses move to the right and their rims come in from the side (in a box wider than a phone, like the one on the card page, the lenses keep the same left edge they would have on a 390 by 844 phone, so they do not vanish to the right), the title goes left on two lines measured with min(vw, vh), the menu becomes a «Menu» pill. Under a finger the lenses follow the touch and swell a little when pressed.

With reduced motion

Everything still in its best pose: the gradient does not slide, the lenses are already in place and do not follow the pointer, the background does not settle; the title, the menu and the button fade in. No drawn pointer.

Pitfalls

  • On negative cycles int(cycle) % 2 is undefined in GLSL ES: the site uses it, here it is mod(cycle, 2.0) < 0.5, which holds for every cycle.
  • The texture has y up and the page y down: every measure is done with y down and only the texture read flips it back (1 - y), or the lenses would read the gradient upside down.
  • offset = st / sd goes to infinity on the rim: that is exactly what draws the dark and rainbow line, but the textures need CLAMP_TO_EDGE and sd must never be exactly zero.
  • Both lenses in one pass would be two holes in the same glass: with two textures the second bends what the first already bent, and that is where the drop shaped curve comes from.
  • GSAP scales the background (1.15 to 1) on its wrapper: the canvas inside always measures its clientWidth, which a transform does not change, so the canvas is not resized on every frame.
  • The title under the mask keeps padding-bottom 0.25em and margin-bottom -0.25em, as on the site: without them the g and the y would be cut while they rise.
  • A slow graphics card (or a machine with no GPU) would make the entrance last three times as long: GSAP has lagSmoothing(0), so the lens and the title land on time, and if the frames stay slow the canvas drops to 0.8 and then 0.6 of its resolution.

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