API Reference › Noise › Noise.cellular2_id
method

Noise.cellular2_id

Noise.cellular2_id(x, y, seed) -> int

Returns the integer **id of the nearest cell** in the same Worley diagram that Noise.cellular2 measures distance in — a stable hash that is identical for every sample point inside a given cell. Use it to assign something discrete per region: the biome or material of a cell, the variant of a scattered prop, a per-region colour. Combine it with the F1 distance to shade toward cell edges.

The id is a hash, so treat it as an opaque label (mod it into your table of choices); it is deterministic across platforms and runs.

Parameters

seedthe field selector (must match the cellular2 call it pairs with)

Example

program CellId {
  entry {
    let seed = 7
    let id = Noise.cellular2_id(fixed(5) / fixed(4), fixed(3) / fixed(4), seed)
    let biome = Math.posmod(id, 4)   # one of 4 biomes for this cell
    print(biome)
  }
}
← All symbols