Skip to main content

Module noise

Module noise 

Source
Expand description

Coherent noise functions: Perlin, simplex, fractal Brownian motion.

Unlike hash functions (which produce uncorrelated “white noise”), coherent noise produces values that vary smoothly — nearby inputs yield similar outputs. This is essential for generating realistic time-series data, spatial fields, and any workload where adjacent coordinates should have correlated values.

The permutation table is built at init time from a seed. The noise evaluation runs at cycle time.

Inputs are u64 coordinates mapped to a float domain via scaling. Outputs are f64 in [-1, 1] (raw noise) or [0, 1] (normalized).

Structs§

FractalNoise1d
1D fractal Brownian motion: layered Perlin noise with decreasing amplitude at each octave. Produces rich, natural-looking signals. Output is f64, roughly in [-1, 1]. Lacunarity is fixed at 2.0 and persistence at 0.5 (standard FBM parameters).
FractalNoise2d
2D fractal Brownian motion: layered Perlin noise in 2D. Produces terrain-like spatial variation. Lacunarity is fixed at 2.0 and persistence at 0.5 (standard FBM parameters).
Perlin1d
1D Perlin noise.
Perlin2d
The perlin_2d node.
PermTable
A permutation table for noise functions. Built from a seed at init time, immutable thereafter. The table is doubled (512 entries) to avoid modular indexing.
Simplex2d
The simplex_2d node.

Functions§

fbm_1d
1D fractal Brownian motion: octaves layers of Perlin noise, each at twice the frequency and half the amplitude of the last.
fbm_2d
2D fractal Brownian motion over Perlin noise, as fbm_1d.
perlin_1d_algo
Evaluate 1D Perlin noise at a given point.
perlin_2d_algo
Evaluate 2D Perlin noise at a given point.
simplex_2d_algo
Evaluate 2D simplex noise at a given point.