Background
The grain behind a hero or a banner: whole pixels, alive, never a blur.
- Drawn with
- WebGL
- Chain
- field → pixelate → ordered → grid → palette
- Code
- @forgeron/shaders: builtInPresets()["role-background"]
/01 → What it is
- Fractal noise through the 8×8 Bayer threshold, in the background, ink and line tones; one fragment shader for the four fields.
- Five looks: the quiet field, the globe, the ember field (the one place it turns orange), the dissolve bands and the CPU dither field of the sub-sites.
- Animates only on screen; one still frame under reduced motion; blank where WebGL is missing.
/02 → Where Forgeron uses it
| Site | Where | Settings |
|---|---|---|
| forgeron.sh | Home hero, behind the village (.saga-bg) | data-shader="field" data-px="4" data-accent="off" · opacity 6 %, screen |
| forgeron.sh | Home, the closing call to action (.cta-glow) | data-shader="ember" data-px="8" |
| forgeron.sh | Pricing, the network block (.net-art) | data-shader="globe" data-px="4" |
| forgeron.sh | Pricing, the closing band | data-shader="dissolve" data-px="8" |
| ui, icon and font galleries | The home heroes | canvas[data-dither] data-px="4" (5 on the font specimen) |
/03 → Versions
- /01 Live
every setting of its field source - /02 Hero, as shown
field · accent off · opacity 0.06, screen - /03 Globe
pixel 4 - /04 Ember
pixel 8 - /05 Dissolve
pixel 8 - /06 Dither field
heat on the CPU · pixel 4 - /07 Dither field, greys
tones={["--bg", "--line-strong", "--ink-dim"]}
/04 → Use it
import { DitherField, FieldShader } from "@forgeron/ui";
// The canvas fills its box: size the box.
<div style={{ position: "relative", height: 320 }}>
<FieldShader mode="field" pixel={4} accent={false} />
</div>
<DitherField pixel={4} /><canvas class="saga-bg" data-shader="field" data-px="4" data-accent="off" aria-hidden="true"></canvas>
<style>
.saga-bg { opacity: 0.06; mix-blend-mode: screen; }
</style>{
"$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
"version": 1,
"name": "role-background",
"source": {
"type": "field",
"mode": "field"
},
"passes": [
{
"type": "pixelate",
"size": 4
},
{
"type": "ordered",
"matrix": 8,
"centered": false,
"origin": "bottom",
"steps": [
[
0,
1
]
]
},
{
"type": "grid",
"gap": 0.16,
"min": 4,
"tone": 0
},
{
"type": "palette",
"tones": [
{
"var": "--bg",
"fallback": "#0a0a0a"
},
{
"var": "--ink",
"fallback": "#ededed"
},
{
"var": "--accent",
"fallback": "#ff4f1f"
}
],
"transparent": []
}
]
}import { builtInPresets } from "@forgeron/shaders";
import { mountPreset } from "@forgeron/shaders/dom";
// WebGL2: every step has GLSL. Validated first.
const handle = mountPreset(canvas, builtInPresets()["role-background"]);
// later: handle?.destroy();import { builtInPresets, chainOf, runCpu, toRgba } from "@forgeron/shaders";
// The CPU side of every step: RGBA bytes for a PNG, or tone paths for an SVG (toSvgPath).
const rgba = toRgba(runCpu(chainOf(builtInPresets()["role-background"]), 320, 200, { time: 1.7 }));API → Options
| Option | Type | Default | Description |
|---|---|---|---|
mode | "ember" | "globe" | "dissolve" | "field" | — | Which field (<FieldShader>). |
pixel | number | 4 | Cell side in CSS pixels. From 4, cells keep a one-pixel gap. |
accent | boolean | true | false draws the brightest cells in ink instead of the ember. |
tones | [string, string, string] | ["--bg", "--line-strong", "--accent"] | <DitherField>: background, low and high tones, tokens or colours. |
pointer | boolean | true | <FieldShader>: follows the pointer over the canvas's parent. |
still | boolean | — | One frame at t = 0. Without it, the reader's prefers-reduced-motion decides. |