Shaders / Primitives / Image dither

Image dither

A picture to five greys and the ember, through the 4×4 Bayer matrix.

Drawn with
GLSL + CPU
Chain
image-dither
Code
@forgeron/shaders: imageDitherMeta, imageDitherGlsl, imageDitherCpu
/01 → What it is
  • Luminance picks between two neighbouring greys through the 4×4 Bayer threshold.
  • Warm pixels (red well above green and blue) become ember over the background.
  • Its source is a picture from the page: the demos go through `mountDitheredImage`.
  • Both sides: GLSL and CPU, with the same result. A cell pass.
  • CPU against GLSL: within a stated share: luminance is float.
/02 → In the examples
ExampleChain
Imageimage → pixelate → image-dither → palette
/03 → Versions
  • /01 Heropixel 3 · gain 1.1
  • /02 Brighterpixel 3 · gain 1.5
/04 → Use it
/01 → In a preset, with its defaults
{
  "type": "image-dither",
  "gain": 1.1,
  "greys": 5
}
/02 → One side per page
import { imageDitherMeta, imageDitherGlsl, imageDitherCpu } from "@forgeron/shaders";

// imageDitherMeta: description and params schema (validation, the editor)
// imageDitherGlsl: the GPU side, for bindChain then glPipeline
// imageDitherCpu: the CPU side, for bindChain then runCpu
API → Options
OptionTypeDefaultDescription
gainnumber1.1Luminance gain.
greysnumber5Greys in the palette; ember is the tone after them.