Shaders / Examples / Transition

Transition

A screen or a state dissolves into the next, pixel by pixel.

Drawn with
WebGL
Chain
field → pixelate → ordered → dissolve → palette
Code
@forgeron/shaders: builtInPresets()["role-transition"]
dissolve pass ·
/01 → What it is
  • The cells switch off in Bayer order as the progress grows; with a transparent tone, the page under the canvas shows through.
  • One canvas over the next screen: no second scene, never a fade.
/02 → Where Forgeron uses it
SiteWhereSettings
GalleryThis page (not yet on a site)built-in preset
/03 → Versions
  • dissolve pass ·
    /01 Liveevery setting of its dissolve pass
  • /02 Heldprogress 0.5
/04 → Use it
/01 → Preset "role-transition" (builtInPresets())
{
  "$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
  "version": 1,
  "name": "role-transition",
  "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": [
        0
      ]
    }
  ]
}
/02 → Plain DOM
import { builtInPresets } from "@forgeron/shaders";
import { mountPreset } from "@forgeron/shaders/dom";

// WebGL2: every step has GLSL. Validated first.
const handle = mountPreset(canvas, builtInPresets()["role-transition"]);
// later: handle?.destroy();
/03 → Static, at build time
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-transition"]), 320, 200, { time: 1.7 }));
API → Options
OptionTypeDefaultDescription
tonenumber0Tone taken.
overnumber[][]Tones that may dissolve; none: all.
progressnumber0.5Share dissolved.
cyclenumber0Seconds for a round trip; 0 holds the progress.
matrix2 | 4 | 88Bayer matrix.