---
title: "cellDistances"
description: "Distances from each pixel to its nearest two cell points, as `(d1, d2)`: the raw material for Voronoi fills and borders."
group: "light"
groupTitle: "Noise, light & materials"
categoryId: "noise"
categorySlug: "noise"
categoryTitle: "Noise"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/noise.ts#L862"
---

# cellDistances

Distances from each pixel to its nearest two cell points, as `(d1, d2)`: the raw material for Voronoi fills and borders.

```ts
cellDistances(slots: {scale: PropRef; seed: PropRef}): Field
```

Import `noise` from `shaders/std` and use `noise.cellDistances`.

`scale` is the number of cells across and `seed` picks a different set of points. The points drift on the layer's clock. Feed it to `cellFill` or `cellBorders`, and wrap it in `share` when both read it.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `slots` | `{scale: PropRef; seed: PropRef}` |  |

## Example

```ts
const cells = share(cellDistances({scale: p('scale'), seed: p('seed')}))
```

## See also

- [`cellFill`](/docs/primitives/noise/cellfill) — A 0–1 fill for each cell: 0 at the cell's point, 1 at its boundary, whatever the cell size.
- [`cellBorders`](/docs/primitives/noise/cellborders) — A mask of the lines between cells: 0 on a boundary, 1 inside a cell.
- [`share`](/docs/primitives/paint/share) — Evaluates a field once and lets several words read the same result.

## Used by

[Voronoi](/docs/components/voronoi)