ludic/docs/language/noise/noise-value2.md
Orkuncakilkaya a4f1494a04
All checks were successful
docs / build-and-deploy (push) Successful in 2s
feat(stdlib): add Noise.* — deterministic fixed-point procedural noise (#3)
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>
2026-08-30 21:50:50 +03:00

30 lines
1.2 KiB
Markdown

---
id: noise-value2
name: Noise.value2
category: noise
kind: namespace-method
tokens: Noise.value2
sig: Noise.value2(x, y, seed) -> fixed
tip: 2D value (lattice) noise, deterministic, in [-1, 1].
order: 1
ns: Noise
member: value2
---
Samples 2D **value noise** at <code>(x, y)</code> for the given <code>seed</code> and returns a <a href="type-fixed"><code>fixed</code></a> in <code>[-1, 1]</code>. Value noise assigns a pseudo-random value to each integer lattice point and smoothly interpolates between them with a quintic fade — the cheapest generator here, with a slightly blocky, retro character that suits low-detail height fields, dithering, and per-cell variation.
Because it is a pure function of <code>(x, y, seed)</code> in fixed point, the same arguments always produce the same value on every platform. Sample at a fractional frequency (scale the coordinates) to change feature size.
Parameters:
- `x`, `y` — the sample coordinates (`fixed`); the integer part picks a cell
- `seed` — the field selector; different seeds give independent worlds
```ludic
program Value {
entry {
let seed = 1337
let n = Noise.value2(fixed(3) / fixed(8), fixed(5) / fixed(8), seed)
print(Math.floor(Noise.unit(n) * fixed(100))) # a 0..100 height
}
}
```