Procedural Terrain
Adapted from Ken Musgrave's procedural fractal terrain algorithm, this implementation is designed to achieve multi-scale feature variation while retaining a high level of detail and customizability.
A fractional Brownian motion framework is used, where various layers (called octaves) of Simplex noise with increasing frequency and decreasing weight are composited together to create a heightmap.
Frequencies increase according to a user-defined parameter
Lacunarity
: The multiplicative factor applied to frequency each octave (it is also applied to the heightmap coordinates as well, discussed below)The heighmap value begins as a simple Simplex noise sample, which then accumulates as we loop through the octaves and apply the following steps:
- Current octave weight is determined by applying a multiplicative factor
Gain
to the signal (our working heightmap value intra-octave) from the last octave - Heightmap point value is multiplied by and then Simplex noise map is resampled to generate a new signal
- The absolute value of the signal is then multiplied by the current octave's weight
- Our signal value is then multiplied by an exponential function
pow(current_octave_frequency, -H)
whereH
is the fractal dimension of the heightmap) and added to the current heightmap value - Finally, the frequency is multiplied by
Lacunarity
to prepare it for the next octave's calculations
These parameters (along with a few quality-of-life additions) allow the user to customize the terrain according their needs. The video below shows a variety of parameter settings and the resulting terrain (rendered as a simple heightmap in TouchDesigner)
Github