Shaders / Primitives / Heat

Heat

The dither field's slow heat, rising from the bottom right.

Drawn with
CPU only
Chain
heat → ordered → palette
Code
@forgeron/shaders: heatMeta, heatCpu
heat source · no settings
/01 → What it is
  • Two slow waves stir a heat that rises from the bottom right corner.
  • CPU only, about 12 frames a second: the field steps, it does not glide.
  • CPU only: a preset with it runs on a 2D canvas.
/02 → In the examples

No example uses it yet: only its own built-in preset.

/03 → Versions
  • heat source · no settings
    /01 Liveevery setting, on "dither-field"
/04 → Use it
/01 → In a preset, with its defaults
{
  "type": "heat"
}
/02 → One side per page
import { heatMeta, heatCpu } from "@forgeron/shaders";

// heatMeta: description and params schema (validation, the editor)
// heatCpu: the CPU side, for bindChain then runCpu
/03 → Preset "dither-field" (builtInPresets())
{
  "$schema": "https://shaders.forgeron.sh/schema/preset.v1.json",
  "version": 1,
  "name": "dither-field",
  "source": {
    "type": "heat"
  },
  "passes": [
    {
      "type": "ordered",
      "matrix": 8,
      "centered": true,
      "origin": "top",
      "steps": [
        [
          0,
          0.9
        ],
        [
          0.45,
          1
        ]
      ]
    },
    {
      "type": "palette",
      "tones": [
        {
          "var": "--bg",
          "fallback": "#0a0a0a"
        },
        {
          "var": "--line-strong",
          "fallback": "#2e2e2e"
        },
        {
          "var": "--accent",
          "fallback": "#ff4f1f"
        }
      ],
      "transparent": []
    }
  ]
}
/04 → Plain DOM
import { builtInPresets } from "@forgeron/shaders";
import { mountPreset } from "@forgeron/shaders/dom";

// On the CPU: a step has no GLSL. Validated first.
const handle = mountPreset(canvas, builtInPresets()["dither-field"]);
// 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()["dither-field"]), 320, 200, { time: 1.7 }));
API → Options

No settings.