
Clouds
A sky of real clouds, lit by the sun, with silver linings and warm sunsets.
This browser cannot run WebGL2, so this is a still image. The code below works wherever WebGL2 is available.
Code
The usage always matches the preview, layers and performance settings included. No build step or package.
Copy embed gives one block to paste into any page or site builder, no setup. For your own code: add clouds.js, ittybitty-shader.js, runtime.js, pointer.js next to this page. Highlighted values follow the controls.
<!-- Quickest: one element. Size it with CSS; it fills its box. -->
<script type="module" src="./ittybitty-shader.js"></script>
<ittybitty-shader effect="clouds" style="width: 100%; aspect-ratio: 16 / 10;"></ittybitty-shader>
<!-- Or with JavaScript, for full control: -->
<canvas id="clouds" aria-hidden="true" style="width: 100%; aspect-ratio: 16 / 10; display: block"></canvas>
<script type="module">
import { clouds } from './clouds.js';
const canvas = document.getElementById('clouds');
const effect = clouds(canvas, {
showSky: true,
showSun: true,
showClouds: true,
showBolt: true,
view: 'horizon',
speed: 0.4,
cover: 0.5,
density: 0.6,
scale: 1,
sun: 0.35,
lightning: 0,
quality: 0.6,
interactive: true,
responsiveness: 0.4,
sky: '#3f7bd0',
horizon: '#bcd7ee',
light: '#fff4e2',
// Performance
dpr: 0.75,
adaptive: true,
});
// Later: effect.set(…), effect.pause(), effect.resume(), effect.destroy()
</script>
Details
The cloud layer is marched through in a few dozen steps: billowing shapes with eroded, cauliflower edges, light absorbed in thick cores and scattered forward through thin ones, grey bases and sunlit tops over a shaded sky that melts into haze at the horizon. The pointer tilts the view. Heavier than most effects, so adaptive resolution is on by default.
- Payload
- 7.9 KB brotli for clouds.js and ittybitty-shader.js and runtime.js and pointer.js, measured at build time. See the method.
- Resolution
- Device pixel ratio capped at 2.
- Frame rate
- Display rate.
- When unseen
- Stops rendering when the canvas leaves the viewport or the tab is hidden, and resumes where it left off.
- Reduced motion
- Shows a single still frame. Controls still update it.
- Layers
- Up to five effects fuse into one shader and one draw call. Filters such as dithering and halftone process the layers beneath them.
- Browsers
- Any browser with WebGL2: Chrome and Edge 56+, Firefox 51+, Safari 15+.
- Licence
- MIT. Copy it, change it, ship it.