28 lines
No EOL
4.4 KiB
HTML
28 lines
No EOL
4.4 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Noise — Ludic</title>
|
||
<meta name="description" content="Procedural noise — the primitive that terrain, caves, biomes, textures, clouds, wind, and object placement are built on.">
|
||
<link rel="stylesheet" href="base.css">
|
||
<link rel="stylesheet" href="docs.css">
|
||
</head>
|
||
<body>
|
||
<header class="nav"><div class="wrap nav-in"><a class="brand" href="index.html"><span class="logo">L</span> Ludic</a><button class="nav-toggle" aria-label="Toggle menu" aria-expanded="false">☰</button><nav class="nav-links"><a href="index.html">Home</a><a href="api.html">API Reference</a><a class="nav-cta" href="https://git.workshopsoft.io/workshopsoft/ludic">Source ↗</a></nav></div></header>
|
||
<main class="wrap item">
|
||
<div class="crumbs"><a href="api.html">API Reference</a> <span>›</span> <span class="here">Noise</span></div>
|
||
<div class="item-head"><span class="kind-badge kind-namespace">namespace</span><h1 id="top">Noise</h1></div>
|
||
<p class="ns-blurb">Procedural noise — the primitive that terrain, caves, biomes, textures, clouds, wind, and object placement are built on. Every generator is implemented in Q16.16 **fixed point** over an integer permutation hash seeded from an explicit seed, so a given seed reproduces the *exact* same field on every platform and every run: native, headless, and (later) wasm all agree bit-for-bit. That is a real edge over float-based engines, whose worlds can drift subtly across CPUs and break shared-seed multiplayer or replays.
|
||
|
||
Coordinates are <a href="type-fixed"><code>fixed</code></a> values. The integer part of a coordinate selects a lattice cell and the fraction interpolates within it, so you scale feature size by sampling at a fractional *frequency* (e.g. multiply coordinates by <code>1/64</code>). Outputs are <code>fixed</code> normalised to <code>[-1, 1]</code>; <a href="noise-unit"><code>Noise.unit</code></a> remaps that to <code>[0, 1]</code> when you want a height or a probability.
|
||
|
||
Pick a generator by feel: <a href="noise-value2"><code>value2</code></a> is cheap and blocky; <a href="noise-perlin2"><code>perlin2</code></a> is the classic gradient noise; <a href="noise-simplex2"><code>simplex2</code></a> is the organic default with fewer directional artifacts; <a href="noise-fbm2"><code>fbm2</code></a> stacks octaves of simplex for natural, detailed fields; and <a href="noise-cellular2"><code>cellular2</code></a> (Worley) gives Voronoi-cell structure for stone, cracks, and biome boundaries. Every sampler is a pure function of <code>(x, y, seed)</code> — no global state, no allocation — so it is safe to call across a whole worldgen pass or a per-pixel fill.
|
||
|
||
Seed worldgen from its own seed (or a dedicated <a href="ns-Random"><code>Random</code></a> stream), kept separate from gameplay RNG, so generating the world never desyncs the simulation.</p>
|
||
<div class="ns-methods"><a class="ns-method" href="noise-value2.html"><code class="nm-sig">Noise.value2(x, y, seed) -> fixed</code><span class="nm-tip">2D value (lattice) noise, deterministic, in [-1, 1].</span></a><a class="ns-method" href="noise-perlin2.html"><code class="nm-sig">Noise.perlin2(x, y, seed) -> fixed</code><span class="nm-tip">2D Perlin gradient noise, deterministic, in [-1, 1].</span></a><a class="ns-method" href="noise-simplex2.html"><code class="nm-sig">Noise.simplex2(x, y, seed) -> fixed</code><span class="nm-tip">2D simplex noise, the organic default, in [-1, 1].</span></a><a class="ns-method" href="noise-fbm2.html"><code class="nm-sig">Noise.fbm2(x, y, seed, octaves) -> fixed</code><span class="nm-tip">Fractal Brownian motion — octaves of simplex, in [-1, 1].</span></a><a class="ns-method" href="noise-cellular2.html"><code class="nm-sig">Noise.cellular2(x, y, seed) -> fixed</code><span class="nm-tip">Worley (cellular) F1 distance to the nearest cell point.</span></a><a class="ns-method" href="noise-cellular2_id.html"><code class="nm-sig">Noise.cellular2_id(x, y, seed) -> int</code><span class="nm-tip">The id of the nearest Worley cell — stable per cell.</span></a><a class="ns-method" href="noise-unit.html"><code class="nm-sig">Noise.unit(n) -> fixed</code><span class="nm-tip">Remap a [-1,1] noise sample to [0,1].</span></a></div>
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |