Skip to content
animorio
IT
Back to the library

Sunset sky background

Backgrounds, WebGL, HoverWebGL, GSAP, CSS onlyAdvancedCompressed weight: Demo 10 KBGSAP 28 KBFreeDownload the zip

A hand-written WebGL animated background for the hero of an invented mountain hut, Hollin Hut: a real sky made with simple scattering of the air, blue overhead and orange and pink near the horizon, soft noise clouds drifting very slowly and lit from below, the low sun above a far ridge in the haze. The pointer moves the sun a little along the horizon, down behind the ridge, and the light of the whole sky follows it; at the bottom a small dial tells the time, the bearing and whether it is golden hour, sunset or afterglow.

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>
<!--
  "Sunset sky 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>Hollin Hut</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/fraunces@5.3.0/full-italic.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/inter-tight@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <!-- the hero of a mountain hut at sunset. A hand-written WebGL shader draws a real sky: simple single scattering
       (blue overhead, orange and rose toward the horizon), soft noise clouds drifting very slowly and lit from below,
       a far ridge in the haze. The pointer moves the sun a little along the horizon and the light of the whole sky
       follows it -->
  <section class="stage" data-stage>
    <canvas class="sky" 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="M3 17.5l6.2-8 3.6 4.4 2.4-2.8 5.8 6.4"/><path d="M2.5 20.5h19" opacity=".5"/>
        </svg>
        Hollin Hut
      </span>
      <nav class="nav">
        <a class="nav__link nav__link--wide" href="#">The hut</a>
        <a class="nav__link nav__link--wide" href="#">Getting here</a>
        <a class="nav__link nav__link--pill" href="#" data-pill><span class="pill__face">Book a bed</span></a>
      </nav>
    </header>

    <div class="hero">
      <h1 class="title" data-title><span class="title__line">Stay up for</span> <span class="title__line"><em>the last light.</em></span></h1>
      <p class="lede" data-in>A stone hut above the tree line, twelve beds and dinner when the sky goes pink.</p>
    </div>

    <footer class="dial" data-in aria-hidden="true">
      <div class="dial__track" data-track>
        <span class="dial__ticks"></span>
        <span class="dial__sun" data-sunmark>
          <svg viewBox="0 0 22 12"><path class="dial__disc" d="M4 11a7 7 0 0 1 14 0"/><path class="dial__line" d="M0 11h22"/></svg>
        </span>
      </div>
      <p class="dial__read">
        <span class="dial__phase" data-phase>Golden hour</span>
        <span class="dial__time" data-time>17:31</span>
        <span class="dial__bearing" data-bearing>WSW 244</span>
      </p>
    </footer>

    <p class="hint" data-in>Move the pointer to walk the sun along the ridge</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.

30 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 “Sunset sky 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 sunset sky the hero of Hollin Hut appears, an invented mountain hut: at the top the name with its mark of two peaks, ‘The hut’, ‘Getting here’ and the ivory ‘Book a bed’ pill; in the middle the heading ‘Stay up for the last light.’ with its second half in soft italics and a line about the stone hut above the tree line, twelve beds and dinner when the sky goes pink. Under the words there is only the sky, drawn by a shader: the blue stays at the top, toward the horizon the air the light crosses at a slant loses its blue and turns orange and pink, the low sun has its glow and a slightly flattened disc, and in front lie two ridges, a far one almost the colour of the haze and a near one in shadow, with a thread of light on the crest toward the sun. A veil of noise clouds drifts very slowly in perspective and catches the light from below: orange near the sun, pink further away, blue grey at the top, with a silver edge on the thin wisps in front of the sun. On its own the sun walks along the horizon from left to right and sets behind the far ridge, the pill is pressed and becomes ‘Bed held for tonight’, then the sun comes back. At the bottom a small dial: a half disc on a ticked line that follows the sun on a spring and dips below the line when it sets, the time going from 17:14 to 17:52, the bearing in degrees and the phase switching between ‘Golden hour’, ‘Sunset’ and ‘Afterglow’. With the pointer the sun follows the hand along the horizon on a heavy spring and the whole sky changes its light with it; the warm halo of the heading follows the sunset too.

How it works

It is all a shader

The background is a hand-written WebGL shader on a single triangle covering the canvas: sky, sun, clouds, ridges and grain. No images and no 3D libraries. Every pixel becomes a viewing direction, with a height above the horizon and an azimuth, as in a camera with a field of about fifty degrees.

Simple scattering

The colour of the sky comes from physics in miniature: the air takes away the blue far more than the red (Rayleigh) and the haze takes away everything in grey (Mie). The light of the low sun crosses a lot of air and arrives orange; looking toward the horizon you look through a lot of air and the sky is warm, looking up through little and the sky stays blue. The glow around the sun is the Mie phase, which throws the light forward.

Clouds lit from below

The clouds lie on a plane above us, seen in perspective (one over the sine of the height), and are a fractal noise bent by another noise. For the light the noise is read one step closer to the sun: where the cloud thins toward the sun that side faces it and lights up, orange in front of the sun and pink further away.

The sun on its path

The pointer gives a number from 0 to 1 along the path of the sun: on the left it is a hand above the ridge, on the right it has already set behind it. The sun catches up on a heavy damped spring, so the sky never jumps; the dial at the bottom has a lighter spring with a pixel of overshoot, and the phase changes with a small blurred fade.

Values to change

NameFileDefaultWhat it changes
STARTscript.js0.32Where the sun is when the page opens: 0 high on the left, 1 set on the right.
SPANscript.js1How far along the horizon the pointer can move the sun.
CLOUDSscript.js1How much of the sky the clouds cover (0 = clear sky).
DRIFTscript.js1How fast the clouds drift.
GLOWscript.js1How bright the light of the sun on the sky and on the clouds is.
HAZEscript.js1How thick the haze on the horizon is.
GRAINscript.js0.03How strong the grain is.
SPEEDscript.js12 = the loop on its own twice as fast, 0.5 = half.
LOOPscript.jstrueRepeats the loop on its own.

Try them in the Playground

When to use it

As the background of the first screen of a mountain hut, a hotel in the mountains or by the sea, a holiday home, a travel or hiking app, an event at sunset: wherever the warm evening light is wanted instead of a photo, moving with the viewer. The colours are --zenith, --sunlight, --rose, --cloud and --land in the CSS.

On phones

The same animations at adapted sizes: the heading is measured on width and height, The hut and Getting here links go and the pill stays, the hint at the bottom right disappears under 900 pixels, the path of the sun narrows to the width of the screen. With a finger the sun follows the gesture.

With reduced motion

The sky stays still at sunset, with the sun just above the ridge, and fades in; the pointer does not move the sun and the pill changes its label without motion.

Pitfalls

  • A hand-made blue to orange gradient looks like a poster: with scattering the colour depends on how much air the light crosses, so moving the sun changes the whole sky the right way, the high clouds too.
  • The blue at the top easily gets lost in the orange when the sun is low: the shader dims the scattered light up high and adds the blue of the zenith, which fades slowly as the sun goes down.
  • Clouds near the horizon in perspective become very thin stripes that flicker: they melt into the haze below a few degrees of height.

Libraries

GSAP 3.15.0, Fraunces (font variabile) 5.3.0, Inter Tight (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 10 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