Pixel Clouds
Billowing cumulus clouds lit from above frame a deep navy opening in the sky, rendered through a fine grid of small rounded cells that each pick one of five tones by ordered dithering, like a vintage screen. The clouds billow and drift all the time. Your cursor parts them like a breath of wind, a click blows a gust that clears a hole and lets it fill back in, scrolling drifts the layers, and on load the picture resolves from big pixels down to fine ones.
Tweak
LIVELIVEPalette
Screen
Motion
Interactive
The cursor parts the clouds, clicks blow a gust
Usage
Follows your tweaks.
import { PixelClouds } from "@/components/inreact/pixel-clouds";
export function Hero() {
return (
<PixelClouds
className="h-screen w-full"
>
{/* optional: your hero content, drawn above the clouds */}
</PixelClouds>
);
}Install with the CLI
npx shadcn@latest add https://inreact.vercel.app/r/pixel-clouds.jsonOr copy the source
Install the dependencies, then save this as components/inreact/pixel-clouds.tsx.
npm install gsap"use client";
import { gsap } from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import { useEffect, useRef, type ReactNode } from "react";
gsap.registerPlugin(ScrollTrigger);
/**
* Pixel Clouds: billowing cumulus around a patch of night sky, printed as a pixel dither.
*
* Soft, puffy clouds lit from above frame a deep navy opening in the sky. The whole
* scene is rendered through a fine grid of small rounded cells, each picking one of
* five tones (navy, slate, grey, stone, cream) by ordered dithering, so the clouds
* read like a vintage screen. The clouds never stop: they billow and drift slowly,
* two layers at different speeds.
*
* It reacts: your cursor is a breath of wind that parts the clouds around it and
* lifts their edges into light; a click blows a gust that clears a hole and lets it
* fill back in, a ring of flipped pixels running out from it; scrolling drifts the
* cloud layers past each other. On load the picture resolves from big pixels down
* to fine ones.
*
* <PixelClouds className="h-screen w-full">
* <YourHero />
* </PixelClouds>
*
* WebGL: one shader (cloud field, lighting, ordered dither into a cell grid).
* GSAP drives every motion. Pauses off-screen; reduced motion shows a still frame;
* a CSS gradient without WebGL.
*/
export interface PixelCloudsProps {
/** The five tones, darkest to lightest. */
sky?: string;
shade?: string;
mid?: string;
light?: string;
highlight?: string;
/** Cell size, in px at 1000px tall (scales with the height). */
pixel?: number;
/** How much of the sky the clouds cover. */
cover?: number;
/** Speed of the drift. */
speed?: number;
/** Cursor wind, click gust. */
interactive?: boolean;
/** Scroll container if the page does not scroll the window. */
scroller?: Element | null;
/** Foreground content, drawn above the clouds. */
children?: ReactNode;
className?: string;
}
const VERT = `attribute vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;
const FRAG = `
precision highp float;
uniform vec2 uRes, uMouse, uGustC;
uniform float uTime, uCell, uIn, uHover, uGust, uGustAmp, uCover, uScroll, uRes0;
uniform vec3 uC0, uC1, uC2, uC3, uC4;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float vnoise(vec2 p) {
vec2 i = floor(p), f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(mix(hash(i), hash(i + vec2(1, 0)), f.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), f.x), f.y);
}
float fbm(vec2 p) {
float v = 0.0, a = 0.5;
mat2 m = mat2(1.6, 1.2, -1.2, 1.6);
for (int i = 0; i < 5; i++) { v += a * vnoise(p); p = m * p; a *= 0.5; }
return v;
}
// puffy: rounded billows, the cauliflower edge of cumulus
float billow(vec2 p) {
float v = 0.0, a = 0.55;
mat2 m = mat2(1.7, 1.1, -1.1, 1.7);
for (int i = 0; i < 4; i++) { v += a * (1.0 - abs(vnoise(p) * 2.0 - 1.0)); p = m * p + 3.1; a *= 0.5; }
return v;
}
// the 4x4 Bayer matrix, the classic ordered dither
float bayer(vec2 c) {
vec2 a = mod(c, 4.0);
float x = a.x, y = a.y;
float b = 0.0;
if (y < 1.0) b = x < 1.0 ? 0.0 : x < 2.0 ? 8.0 : x < 3.0 ? 2.0 : 10.0;
else if (y < 2.0) b = x < 1.0 ? 12.0 : x < 2.0 ? 4.0 : x < 3.0 ? 14.0 : 6.0;
else if (y < 3.0) b = x < 1.0 ? 3.0 : x < 2.0 ? 11.0 : x < 3.0 ? 1.0 : 9.0;
else b = x < 1.0 ? 15.0 : x < 2.0 ? 7.0 : x < 3.0 ? 13.0 : 5.0;
return (b + 0.5) / 16.0;
}
vec2 hash2(vec2 p) { return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453); }
// where cloud mass is (height units, y down): above 0 is cloud
float mass(vec2 q, float t) {
float asp = uRes.x / uRes.y;
vec2 qq = q + (vec2(fbm(q * 1.3 + t * 0.02), fbm(q * 1.3 + 7.0 - t * 0.02)) - 0.5) * 0.1;
// the opening: a tilted channel of sky from the top right down toward the middle left
// on wide screens the opening widens and flattens, so the sky keeps its share of the frame
float wide = clamp((asp - 0.6) / 1.2, 0.0, 1.0);
vec2 c = qq - vec2(asp * mix(0.6, 0.55, wide), mix(0.33, 0.4, wide));
float ang = mix(-0.55, -0.3, wide);
c = mat2(cos(ang), -sin(ang), sin(ang), cos(ang)) * c;
float open = exp(-pow(c.x / mix(0.42, 0.62 * asp * 0.55, wide), 2.0) - pow(c.y / mix(0.15, 0.2, wide), 2.0));
open = max(open, exp(-pow((qq.x - asp * 0.85) / (0.25 + 0.2 * wide), 2.0) - pow((qq.y - 0.05) / 0.12, 2.0)));
float m = 0.42 - open * 1.05 + (fbm(qq * 2.0 + vec2(t * 0.03, uScroll)) - 0.5) * 0.7 + (uCover - 1.0) * 0.35;
vec2 dm = q - uMouse;
m -= exp(-dot(dm, dm) / 0.015) * 0.45 * uHover;
float gr = length(q - uGustC);
m -= exp(-gr * gr / (0.008 + uGust * 0.1)) * 1.2 * uGustAmp;
return m;
}
// one scale of puffs, blended softly into each other (metaballs): adds to the surface height and its slope
void puffs(vec2 q, float sc, float t, float seed, inout float H, inout vec2 G) {
vec2 drift = vec2(t * 0.0006 / sc, uScroll * 0.3);
vec2 g = q / sc + drift;
vec2 i0 = floor(g);
for (int j = -1; j <= 1; j++)
for (int i = -1; i <= 1; i++) {
vec2 id = i0 + vec2(float(i), float(j));
vec2 hj = hash2(id + seed);
// centres stay in the middle half of their cell and radii under 1.2 cells, so the 3x3 search never cuts a puff (no seams)
vec2 c = (id + 0.5 + (hj - 0.5) * 0.5 - drift) * sc;
float m = mass(c, t);
float r = sc * (0.9 + 0.3 * hj.x) * clamp(m * 3.5 + 0.1, 0.0, 1.0);
if (r <= 0.0) continue;
vec2 d = q - c;
float k = 1.0 - dot(d, d) / (r * r);
if (k > 0.0) {
H += r * k * k;
G += r * 2.0 * k * (-2.0 * d / (r * r));
}
}
}
void main() {
vec2 px = vec2(gl_FragCoord.x, uRes.y - gl_FragCoord.y);
// the cell grid; on load the cells start big and resolve down to fine
float cell = uCell * mix(1.0, 7.0, uRes0);
vec2 ci = floor(px / cell);
vec2 cc = (ci + 0.5) * cell;
vec2 q = cc / uRes.y;
float t = uTime;
float H = 0.0;
vec2 G = vec2(0.0);
puffs(q, 0.16, t, 0.0, H, G);
puffs(q, 0.085, t, 11.0, H, G);
puffs(q, 0.05, t, 23.0, H, G);
float edge = 0.022;
float cover = smoothstep(edge * 0.6, edge * 1.4, H);
// the surface: its slope gives a soft normal, with a fine billow so it never looks like plastic
vec2 bump = (vec2(vnoise(q * 60.0 + t * 0.1), vnoise(q * 60.0 + 9.0 - t * 0.1)) - 0.5) * 0.9;
vec3 n = normalize(vec3(-G * 0.35 + bump * 0.3, 1.0));
vec3 L = normalize(vec3(0.55, -0.75, 0.6));
float dif = clamp(dot(n, L), 0.0, 1.0);
// thicker cloud is brighter; thin rims and crevices are shadowed
float thick = smoothstep(edge, edge * 5.0, H);
float cloud = 0.3 + dif * 0.72 + thick * 0.2;
// soft mottling through the cloud body, so tones fall between palette steps and the dither shows
cloud += (fbm(q * 10.0 + vec2(t * 0.05, 0.0)) - 0.5) * 0.16;
float sky = 0.02 + smoothstep(-0.4, 0.08, mass(q, t)) * 0.3 + q.y * 0.05;
float tone = mix(sky, cloud, cover);
// the gust's ring of flipped pixels
float rg = length(q - uGustC) - uGust * 1.1;
tone += exp(-rg * rg / 0.0012) * uGustAmp * 0.35;
tone *= smoothstep(0.0, 0.6, uIn + hash(ci) * 0.3 - 0.15);
// ordered dither into the five tones
float x = clamp(tone, 0.0, 1.0) * 4.0;
float lo = floor(x);
float step = (x - lo) > bayer(ci) ? 1.0 : 0.0;
float k = min(lo + step, 4.0);
vec3 col = k < 0.5 ? uC0 : k < 1.5 ? uC1 : k < 2.5 ? uC2 : k < 3.5 ? uC3 : uC4;
// a few sky pixels catch a faint teal, like the reference's dark patch
if (k < 0.5 && hash(ci + 9.1) > 0.94) col = mix(uC0, vec3(0.3, 0.5, 0.42), 0.55);
// each cell is a small rounded square with a hairline gap to the dark between
vec2 lc = (px - ci * cell) / cell - 0.5;
float r = max(abs(lc.x), abs(lc.y));
float gap = 1.0 / cell;
float inside = 1.0 - smoothstep(0.43 - gap, 0.43 + gap, r + 0.08 * length(lc));
// the gaps between cells take a darker shade of the cell itself, so bright areas stay bright
gl_FragColor = vec4(mix(mix(uC0, col, 0.7), col, inside), 1.0);
}`;
const isReducedMotion = () =>
typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
function rgb(hex: string): [number, number, number] {
let h = hex.replace("#", "");
if (h.length === 3) h = h.replace(/./g, (c) => c + c);
const n = parseInt(h, 16) || 0;
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
}
export function PixelClouds({
sky = "#08101a",
shade = "#3f4d52",
mid = "#7a817f",
light = "#b9bbb2",
highlight = "#eeeddf",
pixel = 5.9,
cover = 1,
speed = 1,
interactive = true,
scroller,
children,
className,
}: PixelCloudsProps) {
const hostRef = useRef<HTMLDivElement>(null);
const props = useRef({ sky, shade, mid, light, highlight, pixel, cover, speed, interactive });
const redraw = useRef<(() => void) | null>(null);
useEffect(() => {
props.current = { sky, shade, mid, light, highlight, pixel, cover, speed, interactive };
redraw.current?.();
}, [sky, shade, mid, light, highlight, pixel, cover, speed, interactive]);
useEffect(() => {
const host = hostRef.current;
if (!host) return;
if (getComputedStyle(host).position === "static") host.style.position = "relative";
const still = isReducedMotion();
const canvas = document.createElement("canvas");
canvas.setAttribute("aria-hidden", "true");
canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:pan-y;";
host.prepend(canvas);
const gl = canvas.getContext("webgl", { alpha: false, antialias: false });
if (!gl) {
const p = props.current;
host.style.background = `radial-gradient(40% 35% at 62% 36%, ${p.sky}, ${p.mid} 70%, ${p.light})`;
canvas.remove();
return;
}
const prog = gl.createProgram()!;
for (const [type, src] of [
[gl.VERTEX_SHADER, VERT],
[gl.FRAGMENT_SHADER, FRAG],
] as const) {
const sh = gl.createShader(type)!;
gl.shaderSource(sh, src);
gl.compileShader(sh);
if (!gl.getShaderParameter(sh, gl.COMPILE_STATUS)) console.error(gl.getShaderInfoLog(sh));
gl.attachShader(prog, sh);
}
gl.linkProgram(prog);
if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) console.error(gl.getProgramInfoLog(prog));
gl.useProgram(prog);
const buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1, -1, 3, -1, -1, 3]), gl.STATIC_DRAW);
const aPos = gl.getAttribLocation(prog, "aPos");
gl.enableVertexAttribArray(aPos);
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
const U = Object.fromEntries(
["uRes", "uMouse", "uGustC", "uTime", "uCell", "uIn", "uHover", "uGust", "uGustAmp", "uCover", "uScroll", "uRes0", "uC0", "uC1", "uC2", "uC3", "uC4"].map((n) => [n, gl.getUniformLocation(prog, n)]),
) as Record<string, WebGLUniformLocation | null>;
let w = 1, h = 1, dpr = 1;
const resize = () => {
dpr = Math.min(window.devicePixelRatio || 1, 2);
w = Math.max(1, host.clientWidth);
h = Math.max(1, host.clientHeight);
canvas.width = Math.round(w * dpr);
canvas.height = Math.round(h * dpr);
gl.viewport(0, 0, canvas.width, canvas.height);
};
resize();
// ---- state: every value GSAP moves (positions in height units) ----
const s = { in: still ? 1 : 0, res: still ? 0 : 1, hover: 0, mx: -9, my: -9, gust: 0, gustAmp: 0, gx: 0, gy: 0, scroll: 0 };
let time = still ? 20 : 0;
const draw = () => {
const p = props.current;
gl.uniform2f(U.uRes, canvas.width, canvas.height);
gl.uniform2f(U.uMouse, s.mx, s.my);
gl.uniform2f(U.uGustC, s.gx, s.gy);
gl.uniform1f(U.uTime, time);
gl.uniform1f(U.uCell, Math.max(2 * dpr, (p.pixel / 1000) * canvas.height));
gl.uniform1f(U.uIn, s.in);
gl.uniform1f(U.uRes0, s.res);
gl.uniform1f(U.uHover, s.hover);
gl.uniform1f(U.uGust, s.gust);
gl.uniform1f(U.uGustAmp, s.gustAmp);
gl.uniform1f(U.uCover, p.cover);
gl.uniform1f(U.uScroll, s.scroll);
gl.uniform3fv(U.uC0, rgb(p.sky));
gl.uniform3fv(U.uC1, rgb(p.shade));
gl.uniform3fv(U.uC2, rgb(p.mid));
gl.uniform3fv(U.uC3, rgb(p.light));
gl.uniform3fv(U.uC4, rgb(p.highlight));
gl.drawArrays(gl.TRIANGLES, 0, 3);
};
const ro = new ResizeObserver(() => {
resize();
draw();
});
ro.observe(host);
if (still) {
draw();
redraw.current = draw;
return () => {
redraw.current = null;
ro.disconnect();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}
// ---- on load: the cells fade in, then resolve from big pixels down to fine ----
const intro = gsap
.timeline({ delay: 0.1 })
.to(s, { in: 1, duration: 1.2, ease: "power2.out" }, 0)
.to(s, { res: 0, duration: 2.2, ease: "steps(6)" }, 0.3);
// ---- cursor: a breath of wind that parts the clouds around it ----
const mxTo = gsap.quickTo(s, "mx", { duration: 0.9, ease: "power3" });
const myTo = gsap.quickTo(s, "my", { duration: 0.9, ease: "power3" });
const hoverTo = gsap.quickTo(s, "hover", { duration: 1.1, ease: "power2.inOut" });
const local = (e: PointerEvent) => {
const r = host.getBoundingClientRect();
return { x: (e.clientX - r.left) / r.height, y: (e.clientY - r.top) / r.height };
};
let first = true;
const move = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
if (first) {
gsap.set(s, { mx: p.x, my: p.y });
first = false;
}
mxTo(p.x);
myTo(p.y);
hoverTo(1);
};
const leave = () => {
first = true;
hoverTo(0);
};
// ---- click: a gust clears a hole that fills back in, a ring of pixels running out ----
const down = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
s.gx = p.x;
s.gy = p.y;
gsap.killTweensOf(s, "gust,gustAmp");
gsap.fromTo(s, { gust: 0 }, { gust: 1, duration: 2.4, ease: "power2.out" });
gsap.timeline().fromTo(s, { gustAmp: 0 }, { gustAmp: 1, duration: 0.2, ease: "power2.out" }).to(s, { gustAmp: 0, duration: 2.4, ease: "sine.inOut" });
};
host.addEventListener("pointermove", move);
host.addEventListener("pointerleave", leave);
host.addEventListener("pointerdown", down);
// ---- scroll: the cloud layers drift past each other ----
const scrollTo = gsap.quickTo(s, "scroll", { duration: 1.4, ease: "power3" });
const st = ScrollTrigger.create({
trigger: host,
scroller: scroller ?? undefined,
start: "top bottom",
end: "bottom top",
onUpdate: (self) => scrollTo((self.progress - 0.5) * 1.6),
});
// ---- loop, only while on screen ----
let visible = true;
let prev = performance.now();
const loop = () => {
const now = performance.now();
const dt = Math.min(0.05, (now - prev) / 1000);
prev = now;
if (!visible) return;
time += dt * props.current.speed;
draw();
};
const io = new IntersectionObserver(([en]) => {
visible = en.isIntersecting;
prev = performance.now();
});
io.observe(host);
gsap.ticker.add(loop);
return () => {
gsap.ticker.remove(loop);
intro.kill();
st.kill();
io.disconnect();
ro.disconnect();
host.removeEventListener("pointermove", move);
host.removeEventListener("pointerleave", leave);
host.removeEventListener("pointerdown", down);
gsap.killTweensOf(s);
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}, [scroller]);
return (
<div ref={hostRef} className={["isolate overflow-hidden", className].filter(Boolean).join(" ")} style={{ background: sky }}>
{children && <div className="relative z-10 h-full">{children}</div>}
</div>
);
}
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
12 propsskystringDarkest tone: the night sky.default "#08101a"default "#08101a"shadestringSecond tone: the cloud shadows.default "#3f4d52"default "#3f4d52"midstringMiddle tone.default "#7a817f"default "#7a817f"lightstringFourth tone.default "#b9bbb2"default "#b9bbb2"highlightstringLightest tone: the sunlit cloud tops.default "#eeeddf"default "#eeeddf"pixelnumberCell size, in px at 1000px tall (scales with the height).default 5.9default 5.9covernumberHow much of the sky the clouds cover.default 1default 1speednumberSpeed of the drift.default 1default 1interactivebooleanCursor wind, click gust.default truedefault truescrollerElement | nullScroll container, if the page does not scroll the window.childrenReactNodeForeground content, drawn above the clouds.classNamestringSize it, e.g. h-screen w-full.