---
title: "quantise"
description: "Reduces each grid cell of the layer inside to 0 or 1 using a dither pattern."
group: "paint"
groupTitle: "Painting"
categoryId: "patterns"
categorySlug: "patterns"
categoryTitle: "Patterns & tiling"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/patterns.ts#L1079"
---

# quantise

Reduces each grid cell of the layer inside to 0 or 1 using a dither pattern.

```ts
quantise(slots: {grid: PixelGrid; pattern: PropRef; threshold: PropRef; spread: PropRef}): GatherStage
```

Import `patterns` from `shaders/std` and use `patterns.quantise`.

Returns a per-pixel level for `ditherInks`. `pattern` is a `compileTime: true` select prop with one of `bayer2`, `bayer4`, `bayer8`, `clusteredDot`, `blueNoise`, `whiteNoise` or `floydSteinberg`. `threshold` 0–1 shifts the cut point; 0.5 is neutral. `spread` 0–1 is how much of the brightness range dithers; lower leaves more solid areas.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `slots` | `{grid: PixelGrid; pattern: PropRef; threshold: PropRef; spread: PropRef}` |  |

## Example

```ts
const levels = quantise({grid, pattern: p('pattern'), threshold: p('threshold'), spread: p('spread')})
```

> **Tip.** Floyd–Steinberg is the costliest pattern: it re-reads 64 cells per pixel. Bayer 4 is the cheap default.

## See also

- [`pixelGrid`](/docs/primitives/patterns/pixelgrid) — The pixel grid of a dither: the layer inside it chopped into square cells of a given size.
- [`ditherInks`](/docs/primitives/patterns/ditherinks) — A dither filter: colors the 0/1 levels from `quantise`, either with two colors of your own or with darkened and brightened versions of the layer's own pixels.

## Used by

[Dither](/docs/components/dither)