Pixelate
The cell size: the source is computed once per cell.
- Drawn with
- GLSL + CPU
- Chain
- field → pixelate → ordered → grid → palette
- Code
- @forgeron/shaders: pixelateMeta, pixelateStep
/01 → What it is
- A layout pass: it comes first, and every pass after it works on cells of `size` CSS pixels.
- No GLSL or CPU of its own: the pipeline reads it (`pixelateStep` is both sides).
- Both sides: GLSL and CPU, with the same result. A layout pass.
/02 → In the examples
| Example | Chain |
|---|---|
| Background | field → pixelate → ordered → grid → palette |
| Image | image → pixelate → image-dither → palette |
| Transition | field → pixelate → ordered → dissolve → palette |
| Progress | constant → pixelate → ordered → hatch → hatch → palette |
| Selection | constant → pixelate → ordered → hatch → palette |
| Feedback | constant → pixelate → ordered → ring → palette |
| Frame burn | front → pixelate → sparks → ordered → palette |
| Lobed burn | front → pixelate → sparks → ordered → palette |
/03 → Versions
- /01 Live
every setting, on "field-ember" - /02 Coarse
size 8 - /03 Fine
size 2
/04 → Use it
{
"type": "pixelate",
"size": 1
}import { pixelateMeta, pixelateStep } from "@forgeron/shaders";
// pixelateMeta: description and params schema (validation, the editor)
// pixelateStep: both sides (the pipeline reads it){
"$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
"version": 1,
"name": "field-ember",
"source": {
"type": "field",
"mode": "ember"
},
"passes": [
{
"type": "pixelate",
"size": 4
},
{
"type": "ordered",
"matrix": 8,
"centered": false,
"origin": "bottom",
"steps": [
[
0,
1
],
[
0.86,
0.12
]
]
},
{
"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()["field-ember"]);
// 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()["field-ember"]), 320, 200, { time: 1.7 }));API → Options
| Option | Type | Default | Description |
|---|---|---|---|
size | number | 1 | Side of one cell in CSS pixels. |