This is an image filter shader — it requires an image input. In React, pass a URL string to the
image prop and it is loaded automatically. In vanilla JS, pass a fully loaded HTMLImageElement to u_image.Usage
- React
- Vanilla JS
Props
The source image to dither. In React, pass a URL string — the component loads it automatically. In vanilla JS, pass a fully loaded
HTMLImageElement as u_image.The dithering algorithm. Use the
DitheringTypes enum (vanilla JS) or string literal (React).| Value | Description |
|---|---|
random | Randomized threshold dithering |
2x2 | 2×2 Bayer ordered dithering |
4x4 | 4×4 Bayer ordered dithering |
8x8 | 8×8 Bayer ordered dithering |
Pixel size of the dithering grid in screen pixels. Range:
0.5 to 20.Number of quantization levels applied to both color modes. Range:
1 to 7.When
true, colors are sampled directly from the original image rather than using the colorFront / colorBack / colorHighlight palette.Inverts the image luminance before dithering. Has no effect when
colorSteps is at its minimum (zero contrast).Foreground (dark) color used in the dithering palette when
originalColors is false.Background (light) color used in the dithering palette when
originalColors is false.Secondary foreground color blended in at the brightest steps. Set equal to
colorFront for classic 2-color dithering.Presets
The following presets are exported from@paper-design/shaders-react:
| Export | Name | Description |
|---|---|---|
defaultPreset | Default | 8×8 Bayer with a green/navy palette |
noisePreset | Noise | Random dithering in monochrome |
retroPreset | Retro | 2×2 Bayer using original image colors |
naturalPreset | Natural | 8×8 Bayer in grayscale with 5 color steps |
Enums
ImportDitheringTypes from @paper-design/shaders when using the vanilla JS API: