Dissolve
Cells switch to one tone in Bayer order: a pixel transition, never a fade.
- Drawn with
- GLSL + CPU
- Chain
- field → pixelate → ordered → dissolve → palette
- Code
- @forgeron/shaders: dissolveMeta, dissolveGlsl, dissolveCpu
/01 → What it is
- As the progress grows, the cells whose Bayer threshold is under it take `tone`; with `cycle` the progress goes there and back.
- Dissolve into a transparent tone and the page under the canvas shows through: the Transition example.
- Both sides: GLSL and CPU, with the same result. A cell pass.
- CPU against GLSL: exact when held; tolerance 0.5 % of pixels on a cycle (measured 0).
/02 → In the examples
| Example | Chain |
|---|---|
| Transition | field → pixelate → ordered → dissolve → palette |
/03 → Versions
- /01 Live
every setting, on "dissolve" - /02 Held
progress 0.5
/04 → Use it
{
"type": "dissolve",
"tone": 0,
"over": [],
"progress": 0.5,
"cycle": 0,
"matrix": 8
}import { dissolveMeta, dissolveGlsl, dissolveCpu } from "@forgeron/shaders";
// dissolveMeta: description and params schema (validation, the editor)
// dissolveGlsl: the GPU side, for bindChain then glPipeline
// dissolveCpu: the CPU side, for bindChain then runCpu{
"$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
"version": 1,
"name": "dissolve",
"source": {
"type": "field",
"mode": "field"
},
"passes": [
{
"type": "pixelate",
"size": 4
},
{
"type": "ordered",
"matrix": 8,
"centered": false,
"origin": "bottom",
"steps": [
[
0,
1
],
[
0.86,
0.12
]
]
},
{
"type": "dissolve",
"tone": 0,
"over": [],
"progress": 0.5,
"cycle": 3,
"matrix": 8
},
{
"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()["dissolve"]);
// 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()["dissolve"]), 320, 200, { time: 1.7 }));API → Options
| Option | Type | Default | Description |
|---|---|---|---|
tone | number | 0 | Tone taken. |
over | number[] | [] | Tones that may dissolve; none: all. |
progress | number | 0.5 | Share dissolved. |
cycle | number | 0 | Seconds for a round trip; 0 holds the progress. |
matrix | 2 | 4 | 8 | 8 | Bayer matrix. |