Skip to content
Michael Malura
734 GitHub stars 5768 npm downloads 56 Projects

Blending Noise Layers

A single fBm looks the same everywhere: wavy, slightly rough, at the same strength in every spot. For clouds that is exactly right. A landscape has plains, hills and mountain ranges, though, and they are not spread out evenly. After Terrain from Noise and Height Curves and Terraces the part that made the biggest difference for me is still missing: putting several noise layers together so that the mountains stand where the land is high.

The demo mixes three layers, shown as grey tiles on the right: continent, mountains and detail. The four chips under the map decide how they are combined. A click on a tile switches that layer off, two sliders set threshold and softness of the mask, dragging the map moves the view and N rolls a new one. Under the map there is a number that compares the relief on the lowlands with the highlands. It starts in Mask mode. Press chip 4 (Add) afterwards and you will see why the mask exists.

Three layers

The continent is an fBm with only two octaves at a low frequency. Perlin noise rarely gets near 0 or 1, so I stretch the values around the middle, otherwise everything would be a grey middle field without a clear coast:

inline float continentAt(float wx, float wy, std::uint32_t seed) {
    const auto n = [seed](float x, float y, int o) { return octaveNoise(x, y, o, seed + 101u); };
    return contrast(fbm(n, wx * kContinentFreq, wy * kContinentFreq, 2, 2.0F, 0.4F), 2.4F);
}

The mountains are a ridged fBm. The trick: mountain crests sit where the noise crosses its middle. There |2n - 1| is zero, and the zero becomes a crest:

inline float ridge(float n, float stretch) { return 1.0F - clamp01(std::fabs(2.0F * n - 1.0F) * stretch); }

stretch narrows the crest, otherwise almost everything would be crest, given how narrow the noise distribution is. Per octave the value is squared and summed (sum += amp * r * r), which makes the crests sharper. The detail is an ordinary fBm at a high frequency. All three layers live in [0, 1]. Each layer has its own noise function with its own seed offset, otherwise they would be correlated.

Adding

The obvious way is the sum. To keep it inside [0, 1] I pick the weights to fit: a base of 0.1, the continent with 0.5, the mountains with 0.4:

case Mode::Add: h = base + kMountainWeight * m; break;

base is kBase + kContinentWeight * c, and the detail comes on top as a small offset of ±0.04. At first glance the result does not look bad. Then you notice the sea is gone. The mountains are added everywhere, also where the continent is low, so the sea floor rises out of the water with mountain ranges and the ocean turns into a lake district. Every spot has the same kind of relief.

The number under the map makes that measurable. It takes all land cells and splits them by the mask: cells where the mask is clearly off (below 5 percent) are lowland, clearly on (above 95 percent) are highland. For both it shows the mean height difference per cell, next to it the ratio. For Add it is about 1.0 in the starting view, lowland and highland are equally steep.

Multiplying

The second idea: the continent scales the mountains instead of just adding to them. Where there is little land, there is little mountain:

case Mode::Multiply: h = base * (kMultBase + kMultGain * m); break;

The factor runs from 0.8 to 1.6, so the relief grows with the height of the land. That is a soft mask without a threshold, and it costs no slider. The ratio rises to about 1.4. The coasts still get relief, because the factor is never zero, and the mountains stay around a little everywhere.

The mask

The third variant turns the continent value into a switch. A mask is 0 where the mountains are not wanted and 1 where they may stand at full height. In between is a transition so there is no edge:

inline float maskOf(float c, float threshold, float softness) { return smoothstep(threshold - softness, threshold + softness, c); }

On the threshold itself the mask is exactly 0.5, however soft the transition is. That is pinned down in the test, because I rely on it when tuning. Then the mask is multiplied with the mountains before they join the base:

case Mode::Mask: h = base + mask * kMountainWeight * m; break;

The lowlands keep the smooth continent, the highlands get the crests on top. With seed 3 the ratio jumps to about 2.5. O tints the area where the mask is off. Pull the threshold down: the mountains spread to the coast. Pull it up and they retreat into the cores of the continents. The softness sets how long the foot of a mountain range is. Set to 0, every range ends at an edge.

Lerp

The fourth variant blends two finished terrains instead of switching one layer on and off: flat plains with just enough height to pass as land, and the full Add terrain.

case Mode::Lerp: h = lerp(kPlainsBase + kPlainsGain * c, base + kMountainWeight * m, mask); break;

Mathematically lerp(base, base + kMountainWeight * m, mask) would be identical to the mask above. The difference only appears when the plains have a shape of their own. Here they are flatter than the continent itself, and the ratio is about 3.9 in the starting view.

Pitfalls

A switched-off layer needs a neutral value. When I switch the continent off, the demo computes with a flat 0.5:

const float c = on.continent ? l.c[i] : 0.5F;
const float m = on.mountains ? l.m[i] : 0.0F;
const float d = on.detail ? l.d[i] : 0.5F;

With 0 for the continent the whole map would be under water in Mask mode. With 0.5 and the default mask it is lowland everywhere, and the mountains stay away because no continent value gets over the threshold.

The statistic caught me out as well. In an earlier version I counted everything with a continent value below the threshold as lowland. That included the whole transition zone, and the foot of the mountains made the lowland steeper. The ratio only reached 1.7. Only after I took out the zone between 5 and 95 percent mask did the difference come through (2.6 in the setting I had then).

The noise itself needs about 20 ms per recompute (288 by 192 cells with ten octaves, measured natively, a bit more in the browser). That is why I keep the three raw layers separate: mode, threshold and on/off only redo the blending (around 0.2 ms), the noise runs only when you pan or roll a new seed.

The code is in the repo under terrain-layers. The project Game Dev Snippets collects all demos of the series. If you want to read on, Red Blob Games explains in Making maps with noise at length how to make maps from noise.

16.11.2026 updated 06.11.2026
Share X Reddit Hacker News LinkedIn E-Mail
Subscribe to new posts RSS JSON