Dawn of Man

Dawn of Man

Not enough ratings
Understanding Amplitudes in Environment xml Files
By SanzSeraph
This guide explains how the <noise_amplitude> element works in Environment configuration files. It will help build your intuition for how amplitudes influence one another so you can more quickly achieve the results you're looking for.
   
Award
Favorite
Favorited
Unfavorite
Introduction
There seems to be a lot of misunderstanding surrounding how amplitude values in the noise_amplitudes element of environment xml files affect terrain generation. After extensive experimentation and reading some comments by Martino, I finally understand how it works and want to pass on what I've learned. If I have gotten anything incorrect, then hopefully the devs will correct me.
How it DOESN'T Work
Several people have suggested that the amplitudes represent certain kinds of entities, such as trees or resource deposits. However, Martino has unequivocally stated exactly what they represent: the amplitudes of various frequencies representing features of various sizes. If you are unfamiliar with the behavior of waves and wave interference patterns, then this will be of little help.

The reason for the confusion mentioned above is that the generation of trees, rocks, flint, and resource deposits depends upon (a) absolute elevation and (b) changes in elevation. For example, resource deposits like copper only appear on steep slopes. Trees only appear at lower elevations, but not the lowest elevations. Therefore, if the amplitudes you have selected result in very few steep slopes, then there will not be any resource deposits.
How it Actually Works
So here's how it actually works. There are eight amplitudes for eight different sizes of features. The first value is for the largest features. These features are so large that a single wave could easily take up the entire length or width of the map. At the other extreme, the far right amplitude represents the height of the very smallest features, things that occupy a single unit of map area.

In nature, when multiple waves collide or overlap, they either add or subtract from one another, producing a total amplitude. Here's a simple illustration. Imagine that you are in the ocean, and there are waves 10 feet high. As you float, your altitude gradually changes from 5ft below sea level to 5ft above seal level. Now, imagine that you use your arms to create a wave in the water. Let's say that the waves you create in this fashion are 5 inches high. If you are at the high point of one of the 5ft waves, then the waves you just created will add to the total height of the wave by 5 inches. The total height of the wave at it's highest point will be 5 feet, 5 inches.

This is precisely how terrain generation works in DoM. If the noise_amplitude value is "0.0 0.8 0.2 0.0 0.0 0.0 0.0 0.0" then the highest points of the map will be 0.8 + 0.2 or 1.0. In Dawn of Man, the maximum height of the terrain at any given point is 1.0. You can prove this by setting the noise_amplitude value to "0.0 1.5 0.0 0.0 0.0 0.0 0.0." The resulting terrain will consist of a bunch of plateaus, because the terrain can't exceed 1.0. If the sum of all amplitudes is greater than 1.0, then this also has the potential to create plateaus. If a "big wave" overlaps with a smaller wave, and the sum of the two amplitudes exceeds 1.0, then a roughly circular plateau will result. Meanwhile, negative amplitudes will be treated as zero.

There also seems to be a limit to the angle of slopes, and this can cause the game to crash. For example, if the 6th amplitude value is greater than 0.3, then the resulting slopes will be too steep, and the game can't spawn resources correctly. But an amplitude greater than 0.3 is perfectly fine for the larger waves, because the ratio of the width to height is much larger, resulting in gentler slopes.

I've already mentioned that resource deposits like copper and tin spawn on steep slopes. Some other rules are that flint boulders, branches and trees do not spawn at 0 elevation. The only exception to this is that trees will spawn on the banks of rivers regardless of elevation. Trees will also not spawn above a certain elevation, or on steep slopes. I haven't experimented enough to know the exact elevation at which trees stop spawning, but that's something you can easily experiment with yourself.

With all of these things in mind, you can make educated guesses not only about what kind of terrain different noise_amplitudes values will produce, but how plentiful copper, tin and iron will be. If you scatter a few 0.0 amplitudes between non-zero amplitudes, for example, steep slopes will be more common, because an amplitude of 0.0 basically turns off that wave frequency and increases the chances that upward and downward slopes will be co-incident.

If you like the topography created by a set of amplitudes, but the distribution of resources and other objects like large boulders isn't to your liking, then you can change the distribution of these objects using the prop_override_prototypes, tree_override_prototypes, detail_override_prototypes and deposit_override_prototype elements. This allows you to change the density, altitude, slope and humidity ranges within which those items will spawn. This part of the environment schema is much easier to understand, and the developer's guide to creating environments documents this feature amply.
5 Comments
Grand Loser 11 Feb @ 11:13pm 
How does one avoid deposits spawning in mid air?
I've been playing with amplitude value around this range:
0.288 0.221 0.034 0.177 0 0 0.022 0
but however I tweak, I seem to end up with at least a few deposits seemingly in the air.
Doom Destroyer 3 May, 2022 @ 2:24am 
This was absolute brilliance from it simplifying such a complex system i applaud you for your great contribution.
SanzSeraph  [author] 7 Apr, 2022 @ 3:25pm 
Merci to both of you!
ChristoLife 7 Apr, 2022 @ 9:51am 
Excellent ! Très bonnes explications, Thanks a lot !
iPinque 31 May, 2020 @ 1:51am 
Brilliant! Thank you.