34 lines
No EOL
2.6 KiB
HTML
34 lines
No EOL
2.6 KiB
HTML
<!doctype html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Noise.fbm2 — Ludic</title>
|
||
<meta name="description" content="Fractal Brownian motion — octaves of simplex, in [-1, 1].">
|
||
<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> <a href="ns-noise.html">Noise</a> <span>›</span> <span class="here">Noise.fbm2</span></div>
|
||
<div class="item-head">
|
||
<span class="kind-badge kind-method">method</span>
|
||
<h1 id="top">Noise.fbm2</h1>
|
||
</div>
|
||
<code class="sig">Noise.fbm2(x, y, seed, octaves) -> fixed</code>
|
||
<div class="desc"><p>Samples **fractal Brownian motion** at <code>(x, y)</code>: it stacks <code>octaves</code> layers of <a href="noise-simplex2"><code>simplex2</code></a>, each at double the frequency and half the amplitude of the last, and normalises by the total amplitude so the result stays a <a href="type-fixed"><code>fixed</code></a> in <code>[-1, 1]</code>. Layering this way adds fine detail on top of broad shapes — the standard recipe for natural-looking terrain, clouds, and marble. More octaves means more detail (and more cost); 4–6 is typical.</p><p>Each octave uses a different derived seed, and the whole thing is deterministic in fixed point across platforms and runs.</p></div>
|
||
<div class="params"><h2>Parameters</h2><div class="param" id="param-seed"><code class="pname">seed</code><span class="pdesc">the base field selector (each octave derives from it)</span></div><div class="param" id="param-octaves"><code class="pname">octaves</code><span class="pdesc">how many layers to sum (higher = more detail)</span></div></div>
|
||
<div class="examples"><h2>Example</h2><pre data-lang="ludic">program Fbm {
|
||
entry {
|
||
let seed = 1337
|
||
let h = Noise.fbm2(fixed(2) / fixed(7), fixed(9) / fixed(7), seed, 5)
|
||
print(Math.floor(Noise.unit(h) * fixed(100))) # detailed 0..100 height
|
||
}
|
||
}</pre></div>
|
||
|
||
<a class="back" href="api.html">← All symbols</a>
|
||
</main>
|
||
<script src="ludic-highlight.js"></script>
|
||
<script>Ludic.highlightAll(); Ludic.installCards(); Ludic.flashTarget();</script>
|
||
</body></html> |