Ember Blooms
Out-of-focus flowers of light glow like embers seen through a wide-open lens: petals blurred into radiant streaks around a darker heart, deep red at the tips and burning gold toward the centre, near blooms large and soft, far ones small and dim, under a fine film grain. They drift slowly upward, turning and breathing; blooms near your cursor warm to gold and turn toward it, a click blossoms a new flower where you clicked, and scrolling drifts the near ones faster than the far.
Tweak
LIVELIVEColour
Blooms
Motion
Interactive
Blooms warm near the cursor, clicks blossom a new one
Usage
Follows your tweaks.
import { EmberBlooms } from "@/components/inreact/ember-blooms";
export function Hero() {
return (
<EmberBlooms
className="h-screen w-full"
>
{/* optional: your hero content, drawn above the blooms */}
</EmberBlooms>
);
}Install with the CLI
npx shadcn@latest add https://inreact.vercel.app/r/ember-blooms.jsonOr copy the source
Install the dependencies, then save this as components/inreact/ember-blooms.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);
/**
* Ember Blooms: out-of-focus flowers of light drifting through the dark.
*
* Soft blooms glow like embers seen through a wide-open lens: petals blurred
* into radiant streaks around a darker heart, deep red at the tips, burning
* orange and gold toward the centre, the nearest ones large and soft, the far
* ones small and dim. A fine film grain sits over everything, like a photograph
* taken in the dark.
*
* They are always alive: the blooms drift slowly upward, turning and breathing.
* It reacts: blooms near your cursor warm to gold and turn toward it; a click
* blossoms a new flower where you clicked; scrolling drifts the near blooms
* faster than the far ones. On load they glow up out of the dark.
*
* <EmberBlooms className="h-screen w-full">
* <YourHero />
* </EmberBlooms>
*
* WebGL: one shader drawing each bloom as soft polar petals with depth of field
* built in (no blur pass needed), additive light with a soft roll-off, and grain.
* GSAP drives every motion. Pauses off-screen; reduced motion shows a still
* frame; a CSS gradient without WebGL.
*/
export interface EmberBloomsProps {
/** Colour at the hot centre of the petals. */
hot?: string;
/** Colour of the petals' body. */
ember?: string;
/** Colour the petals cool to at their tips. */
deep?: string;
/** Background colour. */
background?: string;
/** How many blooms (up to 10). */
count?: number;
/** Size of the blooms. */
size?: number;
/** Amount of film grain. */
grain?: number;
/** Speed of the drift. */
speed?: number;
/** Cursor warmth, click blossom. */
interactive?: boolean;
/** Scroll container if the page does not scroll the window. */
scroller?: Element | null;
/** Foreground content, drawn above the blooms. */
children?: ReactNode;
className?: string;
}
const MAX = 10;
const VERT = `attribute vec2 aPos; void main(){ gl_Position = vec4(aPos, 0.0, 1.0); }`;
const FRAG = `
precision highp float;
uniform vec2 uRes, uMouse;
uniform float uTime, uIn, uGrain, uHover;
uniform vec3 uHot, uEmber, uDeep, uBg;
// each bloom: position (x, y), radius, spin; and heat, petal count, seed, depth
uniform vec4 uA[${MAX}];
uniform vec4 uB[${MAX}];
float hash(vec2 p) {
vec3 p3 = fract(vec3(p.xyx) * 0.1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
float H = uRes.y;
vec2 p = gl_FragCoord.xy / H;
vec3 light = vec3(0.0);
for (int i = 0; i < ${MAX}; i++) {
vec4 A = uA[i];
vec4 B = uB[i];
if (A.z <= 0.0) continue;
vec2 d = p - A.xy;
float r = length(d) / A.z;
if (r > 2.2) continue;
float a = atan(d.y, d.x) + A.w;
float k = B.y;
float blur = 0.12 + 0.2 * B.w;
// each petal is a soft rounded blade: a blurred capsule from near the heart out to its tip;
// check this petal and its neighbours so overlapping blades blend
float petal = 0.0;
float tipT = 0.0;
float pc = floor(a * k / 6.2831853 + 0.5);
for (int j = -1; j <= 1; j++) {
// wrap the petal number round the circle, so there is no seam where the angle wraps
float pi = mod(pc + float(j), k);
float hp = hash(vec2(pi, B.z));
float ang = pi * 6.2831853 / k + (hp - 0.5) * 0.18;
vec2 dir = vec2(cos(ang), sin(ang));
vec2 q = vec2(cos(a), sin(a)) * r;
float plen = 0.7 + 0.35 * hp + 0.05 * sin(uTime * 0.8 + pi + B.z);
float t = clamp(dot(q, dir), 0.18, plen);
float dist = length(q - dir * t);
float wdt = 0.05 + 0.05 * (t / plen) + 0.03 * hp;
float bl = 1.0 - smoothstep(wdt - blur * 0.3, wdt + blur, dist);
bl *= 0.65 + 0.5 * hp;
if (bl > petal) { petal = bl; tipT = t / plen; }
}
// a soft glow round the whole flower, and its darker heart
float halo = exp(-r * r * 2.5) * 0.16;
float heart = smoothstep(0.1, 0.32, r);
float v = (petal + halo) * heart;
// the heart itself: a deep, dim glow rather than a black hole
v += exp(-r * r / 0.02) * 0.22;
// colour: deep red at the tips, ember along the petal, gold toward the centre, hotter when warmed
float t = clamp((1.0 - tipT) * 0.85 + B.x * 0.5, 0.0, 1.0);
vec3 col = mix(uDeep, uEmber, smoothstep(0.0, 0.5, t));
col = mix(col, uHot, smoothstep(0.45, 1.0, t) * (0.5 + 0.5 * B.x));
// far blooms are dimmer
light += col * v * mix(0.85, 0.3, B.w) * (0.85 + 0.6 * B.x);
}
// the cursor's own faint warmth
vec2 dm = p - uMouse;
light += uEmber * exp(-dot(dm, dm) / 0.03) * 0.06 * uHover;
light *= uIn;
// a soft roll-off, so hot centres glow golden instead of clipping to white
vec3 col = uBg + light / (1.0 + max(light - 0.7, 0.0) * 0.9);
// film grain, strongest in the half-tones
float lum = dot(col, vec3(0.3, 0.55, 0.15));
float g = hash(floor(gl_FragCoord.xy) + vec2(floor(uTime * 12.0) * 37.0, 0.0)) - 0.5;
col += g * uGrain * (0.025 + 0.12 * smoothstep(0.0, 0.5, lum));
gl_FragColor = vec4(clamp(col, 0.0, 1.0), 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];
}
type Bloom = { x: number; y: number; r: number; spin: number; spinV: number; heat: number; warm: number; k: number; seed: number; depth: number; grow: number; vy: number; phase: number };
const rand = (a: number, b: number) => a + Math.random() * (b - a);
export function EmberBlooms({
hot = "#ffaa1a",
ember = "#ff5a1e",
deep = "#8a0f14",
background = "#060404",
count = 5,
size = 1,
grain = 1,
speed = 1,
interactive = true,
scroller,
children,
className,
}: EmberBloomsProps) {
const hostRef = useRef<HTMLDivElement>(null);
const props = useRef({ hot, ember, deep, background, count, size, grain, speed, interactive });
const redraw = useRef<(() => void) | null>(null);
useEffect(() => {
props.current = { hot, ember, deep, background, count, size, grain, speed, interactive };
redraw.current?.();
}, [hot, ember, deep, background, count, size, grain, 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(circle at 30% 70%, ${p.hot}, ${p.ember} 12%, ${p.deep} 22%, transparent 32%), radial-gradient(circle at 70% 30%, ${p.ember}, ${p.deep} 14%, transparent 24%), ${p.background}`;
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", "uTime", "uIn", "uGrain", "uHover", "uHot", "uEmber", "uDeep", "uBg", "uA", "uB"].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();
// ---- the blooms (height units, y up) ----
const make = (anywhere: boolean, x?: number, y?: number): Bloom => {
const depth = Math.random();
return {
x: x ?? rand(0.05, Math.max(0.3, w / h - 0.05)),
y: y ?? (anywhere ? rand(0.05, 0.95) : rand(-0.4, -0.25)),
r: rand(0.12, 0.19) * (1.15 - depth * 0.55),
spin: rand(0, Math.PI * 2),
spinV: rand(-0.08, 0.08),
heat: 0,
warm: 0,
k: Math.floor(rand(12, 17)),
seed: rand(0, 100),
depth,
grow: 1,
vy: rand(0.012, 0.03) * (1.2 - depth * 0.6),
phase: rand(0, 6.28),
};
};
const blooms: Bloom[] = [];
const fill = () => {
const n = Math.max(1, Math.min(MAX, Math.round(props.current.count)));
while (blooms.length < n) blooms.push(make(true));
while (blooms.length > n) blooms.pop();
};
fill();
const A = new Float32Array(MAX * 4), B = new Float32Array(MAX * 4);
const s = { in: still ? 1 : 0, mx: -9, my: -9, hover: 0, scroll: 0 };
let time = 0;
const draw = () => {
const p = props.current;
fill();
A.fill(0);
B.fill(0);
blooms.forEach((b, i) => {
// breathing: each bloom swells a little in its own rhythm
const breathe = 1 + 0.05 * Math.sin(time * 0.6 + b.phase);
const par = s.scroll * (1.3 - b.depth);
A.set([b.x, b.y + par, b.r * p.size * breathe * b.grow, b.spin], i * 4);
B.set([Math.min(1, b.heat + b.warm), b.k, b.seed, b.depth], i * 4);
});
gl.uniform2f(U.uRes, canvas.width, canvas.height);
gl.uniform2f(U.uMouse, s.mx, s.my);
gl.uniform1f(U.uTime, time);
gl.uniform1f(U.uIn, s.in);
gl.uniform1f(U.uGrain, p.grain);
gl.uniform1f(U.uHover, s.hover);
gl.uniform3fv(U.uHot, rgb(p.hot));
gl.uniform3fv(U.uEmber, rgb(p.ember));
gl.uniform3fv(U.uDeep, rgb(p.deep));
gl.uniform3fv(U.uBg, rgb(p.background));
gl.uniform4fv(U.uA, A);
gl.uniform4fv(U.uB, B);
gl.drawArrays(gl.TRIANGLES, 0, 3);
};
const ro = new ResizeObserver(() => {
resize();
draw();
});
ro.observe(host);
if (still) {
time = 2;
draw();
redraw.current = draw;
return () => {
redraw.current = null;
ro.disconnect();
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}
// ---- on load: they glow up out of the dark ----
const intro = gsap.to(s, { in: 1, duration: 2.4, ease: "power2.inOut", delay: 0.1 });
// ---- cursor: nearby blooms warm toward gold and turn toward it ----
const mxTo = gsap.quickTo(s, "mx", { duration: 0.6, ease: "power3" });
const myTo = gsap.quickTo(s, "my", { duration: 0.6, ease: "power3" });
const hoverTo = gsap.quickTo(s, "hover", { duration: 0.8, ease: "power2" });
const local = (e: PointerEvent) => {
const r = host.getBoundingClientRect();
return { x: (e.clientX - r.left) / r.height, y: (r.bottom - e.clientY) / 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 new bloom blossoms where you clicked ----
const down = (e: PointerEvent) => {
if (!props.current.interactive) return;
const p = local(e);
const b = make(true, p.x, p.y);
b.depth = 0.1;
b.r = rand(0.15, 0.2);
b.grow = 0;
b.heat = 1;
// replace the faintest, furthest bloom so the frame never crowds
let k = 0;
blooms.forEach((o, i) => {
if (o.depth > blooms[k].depth) k = i;
});
blooms[k] = b;
gsap.to(b, { grow: 1, duration: 1.8, ease: "elastic.out(1, 0.6)" });
gsap.to(b, { heat: 0, duration: 3.5, ease: "power2.out", delay: 0.4 });
gsap.fromTo(b, { spin: b.spin - 0.6 }, { spin: b.spin, duration: 2.2, ease: "power3.out" });
};
host.addEventListener("pointermove", move);
host.addEventListener("pointerleave", leave);
host.addEventListener("pointerdown", down);
// ---- scroll: near blooms drift faster than far ones ----
const scrollTo = gsap.quickTo(s, "scroll", { duration: 1.2, ease: "power3" });
const st = ScrollTrigger.create({
trigger: host,
scroller: scroller ?? undefined,
start: "top bottom",
end: "bottom top",
onUpdate: (self) => scrollTo((self.progress - 0.5) * 0.5),
});
// ---- loop, only while on screen: drift up, turn, warm near the cursor ----
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;
const sp = props.current.speed;
time += dt * sp;
for (let i = 0; i < blooms.length; i++) {
const b = blooms[i];
b.y += b.vy * dt * sp;
b.x += Math.sin(time * 0.3 + b.phase) * 0.004 * dt * sp;
// nearby blooms warm and turn toward the cursor
const dx = s.mx - b.x, dy = s.my - b.y;
const near = Math.exp(-(dx * dx + dy * dy) / (b.r * b.r * 4)) * s.hover;
b.warm += (near * 0.85 - b.warm) * Math.min(1, dt * 3);
b.spin += (b.spinV + near * 0.25) * dt * sp;
// drifted off the top: a new one rises from below
if (b.y - b.r * 1.5 > 1 + 0.3) blooms[i] = make(false);
}
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);
blooms.forEach((b) => gsap.killTweensOf(b));
canvas.remove();
gl.getExtension("WEBGL_lose_context")?.loseContext();
};
}, [scroller]);
return (
<div ref={hostRef} className={["isolate overflow-hidden", className].filter(Boolean).join(" ")} style={{ background }}>
{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 propshotstringColour at the hot centre of the petals.default "#ffaa1a"default "#ffaa1a"emberstringColour of the petals' body.default "#ff5a1e"default "#ff5a1e"deepstringColour the petals cool to at their tips.default "#8a0f14"default "#8a0f14"backgroundstringBackground colour.default "#060404"default "#060404"countnumberHow many blooms (up to 10).default 5default 5sizenumberSize of the blooms.default 1default 1grainnumberAmount of film grain.default 1default 1speednumberSpeed of the drift.default 1default 1interactivebooleanCursor warmth, click blossom.default truedefault truescrollerElement | nullScroll container, if the page does not scroll the window.childrenReactNodeForeground content, drawn above the blooms.classNamestringSize it, e.g. h-screen w-full.