Skip to content

feat(fx): GradientFx, animated grain gradient background (HOLD 3.1) - #555

Merged
lorant-one merged 2 commits into
previewfrom
feat/fx-gradient-field
Nov 23, 2026
Merged

lorant-one merged 2 commits into
previewfrom
feat/fx-gradient-field

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

HOLD for 3.1. Targets the 3.0 branch like core#552 (mascot mediums) because fx only lives there so far. Don't merge before 3.0.0 ships.

What

<GradientFx> in @once-ui-system/fx: soft colour bands that drift slowly through each other under film grain, the "blurred mesh + grain" hero look. Put it behind content; children sit on top.

<GradientFx colors={["#0c0f14", "#123540", "#2a8f9a", "#5fd6c4", "#eef6e8"]} angle={-28} seed={2}>
  …hero…
</GradientFx>
Prop
colors Ramp from shadow to highlight, 2–6 stops: tokens, --vars or CSS colours. The first is the ground. Default: page background → brand → accent from the theme. Re-read on theme change.
speed Speed (slow/medium/fast or a multiplier)
grain 0–1, default 0.35
blur 0 (crisp ribbons) – 1 (haze), default 0.6
angle Direction the bands run, degrees
seed Same seed, same field
reducedMotion "auto" / true / false, as the other effects

How

  • Shader: a small fragment shader with stretched simplex noise, a gentle domain warp, a colour ramp and per-frame hash grain, plus 1/255 dither against banding.
  • Cost: 1 CSS px per pixel (≤2.4 MP), capped at 30 fps, low-power context. It sleeps off screen (IntersectionObserver) and in hidden tabs, and the clock resumes where it stopped.
  • Reduced motion: one still frame with static grain. Low-end devices also get the still frame through useReducedMotion.
  • Fallback: the server and browsers without WebGL get blurred CSS blobs placed by the seed, plus SVG grain. The shader fades in over them and the CSS layer then stops painting. A lost context returns to the CSS look.
  • internal/shaderStage.ts: the WebGL counterpart of canvasStage.ts. It handles compile, the full-screen triangle, resize, the fps cap and visibility. It's meant as the shared setup for later shader effects, including a WebGL mascot medium if core#552 ever needs one; those mediums are SVG-filter based today.

Screens

Proof page: apps/dev → /gradient-fx-proof. Screens and a 7 s clip are in the project files under gradient-fx/: dark, light, CSS fallback (WebGL off) and the hero clip.

Checks

  • vitest run in fx: 243 pass, including 7 new GradientFx tests. They cover the 30 fps cap, no loop off screen, the single still frame under reduced motion, unmount cleanup, the CSS fallback without WebGL and deterministic SSR markup.
  • tsc --noEmit is clean, Biome is clean on the new files, and the fx lint gate stays at baseline.
  • once-ui-validate-ai-code is clean on the component and the proof page.
  • The SSR/hydration match was checked in the dev app; values are rounded so server and client agree.

Follow-ups (not here)

  • Generate the ramp from a brand kit's palette.
  • Offer it as a hero background in Frametic and Aveiro.
  • Docs page and the screenshot in the fx catalogue.

Generated by Claude Code

A WebGL field of soft colour bands that drift through each other under
film grain, with a CSS fallback (blurred blobs and SVG grain) for the
server and browsers without WebGL. Sleeps off screen, holds a still frame
under reduced motion, capped at 30 fps. Props: colors (a ramp, tokens or
CSS), speed, grain, blur, angle, seed.

internal/shaderStage.ts is the shared WebGL setup for shader effects.
Proof page at apps/dev /gradient-fx-proof.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtzJGRzqpqejDC4ZW8N
@lorant-one lorant-one added the HOLD 3.1 label Nov 19, 2026 — with Claude
@lorant-one lorant-one self-assigned this Nov 19, 2026
@lorant-one
lorant-one changed the base branch from feat/3-0-breaking-cleanup to preview November 23, 2026 20:50
@lorant-one
lorant-one merged commit 9c7e323 into preview Nov 23, 2026
9 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
27 tasks done
@lorant-one lorant-one added the approved label Nov 24, 2026 — with Claude
@lorant-one
lorant-one deleted the feat/fx-gradient-field branch November 29, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants