Shaders / Primitives / Reveal

Reveal

Tones appear along a Bayer-jittered front that scans the rows.

Drawn with
GLSL + CPU
Chain
field → pixelate → ordered → reveal → palette
Code
@forgeron/shaders: revealMeta, revealGlsl, revealCpu
reveal pass ·
/01 → What it is
  • The front goes down the rows, left to right in each row; a cell wears the `front` tones before it settles in its own.
  • The cell-local form of the Title example's reveal, which also shifts pixels with a wave.
  • Both sides: GLSL and CPU, with the same result. A cell pass.
  • CPU against GLSL: tolerance 1 % of pixels (measured 0).
/02 → In the examples
ExampleChain
Titletone → ordered → reveal → palette
/03 → Versions
  • reveal pass ·
    /01 Liveevery setting, on "reveal"
  • /02 Slowduration 3
/04 → Use it
/01 → In a preset, with its defaults
{
  "type": "reveal",
  "duration": 1.5,
  "hold": 1.5,
  "loop": false,
  "front": [
    3,
    2
  ],
  "band": 0.06,
  "dither": 0.12,
  "matrix": 8
}
/02 → One side per page
import { revealMeta, revealGlsl, revealCpu } from "@forgeron/shaders";

// revealMeta: description and params schema (validation, the editor)
// revealGlsl: the GPU side, for bindChain then glPipeline
// revealCpu: the CPU side, for bindChain then runCpu
/03 → Preset "reveal" (builtInPresets())
{
  "$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
  "version": 1,
  "name": "reveal",
  "source": {
    "type": "field",
    "mode": "globe"
  },
  "passes": [
    {
      "type": "pixelate",
      "size": 4
    },
    {
      "type": "ordered",
      "matrix": 8,
      "centered": false,
      "origin": "bottom",
      "steps": [
        [
          0,
          1
        ],
        [
          0.86,
          0.12
        ]
      ]
    },
    {
      "type": "reveal",
      "duration": 1.5,
      "hold": 1.5,
      "loop": true,
      "front": [
        2,
        1
      ],
      "band": 0.06,
      "dither": 0.12,
      "matrix": 8
    },
    {
      "type": "palette",
      "tones": [
        {
          "var": "--bg",
          "fallback": "#0a0a0a"
        },
        {
          "var": "--ink",
          "fallback": "#ededed"
        },
        {
          "var": "--accent",
          "fallback": "#ff4f1f"
        }
      ],
      "transparent": []
    }
  ]
}
/04 → 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()["reveal"]);
// later: handle?.destroy();
/05 → 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()["reveal"]), 320, 200, { time: 1.7 }));
API → Options
OptionTypeDefaultDescription
durationnumber1.5Seconds of sweep.
holdnumber1.5Seconds settled.
loopbooleanfalseRestart after the hold.
frontnumber[][3,2]Tones worn at the front.
bandnumber0.06Share per tone.
dithernumber0.12Bayer jitter.
matrix2 | 4 | 88Bayer matrix.