Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.random

A deterministic per-element random Float in [min, max): min + (max - min) times the field.rand draw keyed by seed, graphId, nodeId and channel. A seed replays the same field on every machine, equal to hash.unitFloat to the bit.

Inputs

  • seed (Float). Default 1. Picks which draw the whole field is. The same seed replays the same value at every element on every machine; a different seed redraws all of them.
  • channel (Float). Default 0. A second independent draw off the same seed. Two of these sharing a seed and a channel produce the identical field.
  • min (Float). Default 0. The bottom of the range each value lands in, reachable.
  • max (Float). Default 1. The top of the range, approached and not reached. Below min the range runs downward.
  • graphId (String). Default "field". The graph name the draw is keyed by.
  • nodeId (String). Default "random". The node name the draw is keyed by.

Outputs

  • field: a Float field in [min, max).

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.random({ seed = 4, min = 5, max = 6 }) })