feat(stdlib): add Noise.* — deterministic fixed-point procedural noise (#3)
All checks were successful
docs / build-and-deploy (push) Successful in 2s
All checks were successful
docs / build-and-deploy (push) Successful in 2s
A Noise.* namespace for procedural generation, implemented entirely in Q16.16 fixed point over an integer permutation hash so a seed reproduces the exact same field on every platform and run (native/headless/wasm) — the determinism edge over float noise that drifts across CPUs. - value2 / perlin2 / simplex2 — value, gradient, and simplex noise -> [-1,1] - fbm2(x,y,seed,octaves) — fractal Brownian motion (octaves of simplex) - cellular2 / cellular2_id — Worley F1 distance + nearest-cell id - unit(n) — remap [-1,1] -> [0,1] Covers issue phases 1–2 fully plus cellular from phase 3; domain warp, ridged/ billow, and sample1/sample3 remain as follow-ups. Pure integer IR, C-free; cellular/fbm reuse the math prelude's fx_sqrt. - examples/library/noise.ludic: asserts the invariants a fixed-point generator must hold (Perlin == 0 at lattice points, every sampler within [-1,1], reproducibility, seed sensitivity, non-negative cellular distance). Wired into `x test` (now 52 passed). - docs: a new Noise section + per-symbol pages; inventory and coverage pass. - seed regenerated; `x bootstrap-cfree` fixpoint holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
2ddf830f0b
commit
a4f1494a04
17 changed files with 11720 additions and 10432 deletions
31
docs/language/noise/noise-cellular2_id.md
Normal file
31
docs/language/noise/noise-cellular2_id.md
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
id: noise-cellular2_id
|
||||
name: Noise.cellular2_id
|
||||
category: noise
|
||||
kind: namespace-method
|
||||
tokens: Noise.cellular2_id
|
||||
sig: Noise.cellular2_id(x, y, seed) -> int
|
||||
tip: The id of the nearest Worley cell — stable per cell.
|
||||
order: 6
|
||||
ns: Noise
|
||||
member: cellular2_id
|
||||
---
|
||||
|
||||
Returns the integer **id of the nearest cell** in the same Worley diagram that <a href="noise-cellular2"><code>Noise.cellular2</code></a> 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:
|
||||
- `x`, `y` — the sample coordinates (`fixed`)
|
||||
- `seed` — the field selector (must match the `cellular2` call it pairs with)
|
||||
|
||||
```ludic
|
||||
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)
|
||||
}
|
||||
}
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue