Shaders / Examples / Lobed burn

Lobed burn

A ring of fire with drifting lobes that spreads from the centre, or closes onto it.

Drawn with
WebGL
Chain
front → pixelate → sparks → ordered → palette
Code
@forgeron/shaders: builtInPresets()["burn-lobed-open"]
front source ·
/01 → What it is
  • The picture spreads from the centre behind a lobed front whose lobes drift. Run backwards, the front closes on the centre and burns the picture away.
  • The same two-ring Bayer fringe, widening from 12 px a ring at the centre to 24 near the edges.
  • Embers in white and greys only, so the two burns do not look alike.
/02 → Where Forgeron uses it
SiteWhereSettings
forgeron.shHome, the opening story: the village appears on loadburn-lobed-open · 1.9 s
GalleryThis page: the close directionburn-lobed-close · not yet on a site
/03 → Versions
  • front source ·
    /01 Liveevery setting of its front source
  • /02 Closethe picture burns away to the centre
/04 → Use it
/01 → Driven by the page (the scroll, a clock)
import { builtInPresets } from "@forgeron/shaders";
import { mountPreset } from "@forgeron/shaders/dom";

// Progress comes from the page: the preset redraws when it is set.
const preset = builtInPresets()["burn-lobed-open"];
const handle = mountPreset(canvas, { ...preset, source: { ...preset.source, driven: true } });
addEventListener("scroll", () => handle?.set({ progress: scrollY / innerHeight }));
/02 → Preset "burn-lobed-open" (builtInPresets())
{
  "$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
  "version": 1,
  "name": "burn-lobed-open",
  "source": {
    "type": "front",
    "shape": "lobed",
    "direction": "open",
    "cycle": 1.9,
    "hold": 0.9,
    "ring": 4
  },
  "passes": [
    {
      "type": "pixelate",
      "size": 4
    },
    {
      "type": "sparks",
      "tick": 0.12,
      "fly": 0.004
    },
    {
      "type": "ordered",
      "matrix": 4,
      "centered": false,
      "origin": "top",
      "steps": [
        [
          0,
          1
        ],
        [
          1.5,
          0
        ],
        [
          2.5,
          0
        ],
        [
          3.5,
          0
        ]
      ]
    },
    {
      "type": "palette",
      "tones": [
        {
          "var": "--bg",
          "fallback": "#0a0a0a"
        },
        {
          "var": "--bg",
          "fallback": "#0a0a0a"
        },
        {
          "var": "--ink",
          "fallback": "#ededed"
        },
        {
          "var": "--ink-muted",
          "fallback": "#ff4f1f"
        },
        {
          "var": "--ink-dim",
          "fallback": "#ff6b81"
        }
      ],
      "transparent": [
        1
      ]
    }
  ]
}
/03 → 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()["burn-lobed-open"]);
// later: handle?.destroy();
/04 → 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()["burn-lobed-open"]), 320, 200, { time: 1.7 }));
API → Options
OptionTypeDefaultDescription
shape"rect" | "lobed""rect"A rectangle closing onto a band, or a lobed ring from the centre.
direction"close" | "open""close"Burn the picture away, or let it in.
progressnumber0.5Progress, 0 to 1.
cyclenumber0Seconds per run; 0 holds the progress.
holdnumber0.9Seconds held.
drivenbooleanfalseProgress comes from the page (the input set while it runs).
ringnumber4Cells per ring.
leftnumber0Closes onto: left (rect).
topnumber0.33Closes onto: top (rect).
rightnumber1Closes onto: right (rect).
bottomnumber0.67Closes onto: bottom (rect).
outside"page" | "keep""page"Cover what lies outside the edge, or leave it to the page.
grownumber3Ring growth, cells (lobed).
ampnumber0.18Lobe depth (lobed).
ticknumber0.18Seconds per draw.
offsetnumber6Ember depth, cells.
wobblenumber1Wave amplitude, cells.
densitynumber0.5Chance, nearest layer.
falloffnumber0.07Chance lost a layer.
flynumber0.003Flying spark chance.
reachnumber10Flight distance, cells.
tonesnumber[][2,3,4]Levels written: outer, middle, inner.