You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This document details the mathematical equations used in src/noise.rs for generating 2D Perlin Noise and Fractal Brownian Motion (FBM).
1. Linear Interpolation (Lerp)
Linear interpolation calculates a value between a start point $a$ and an end point $b$ based on a normalized weight $t \in [0, 1]$:
$$\text{lerp}(a, b, t) = a + t \cdot (b - a) = (1 - t) \cdot a + t \cdot b$$
2. Quintic Smoothstep S-Curve
To guarantee smooth transitions (continuous first and second derivatives) across grid boundaries, the fractional distance vector $\mathbf{f}$ is mapped through a quintic polynomial:
For a cell corner with integer coordinate $\mathbf{i}_c$, gradient vector $\mathbf{g}_c = \text{hash}(\mathbf{i}_c)$, and target coordinate $\mathbf{p}$, the distance vector is $\mathbf{d}_c = \mathbf{p} - \mathbf{i}_c$. The scalar influence $n_c$ of that corner is:
To construct natural, multi-scale noise, multiple "octaves" of Perlin noise are added together, doubling the frequency and halving the amplitude at each step: