# 2D Terra(ria)in generation - Accidental noise

I'm currently trying to implement terrain generation as described on the following page: http://accidentalnoise.sourceforge.net/minecraftworlds.html.

But I have issues understanding how to interpret the noise function values.

1) What does the gradient function in the ANL library exactly do? I see its purpose is to create the gradient, but I don't understand what the output/input for it exactly is. You input the line segments (0,0,0,1) but what does it return?

2) How should / can perlin noise values be interpreted? In my project I have ported the 2d noise function defined by stefan gustavson to python but I don't know what to do with the values itself? People keep posting images of "perlin" noise, but I assume that are the values mapped to a RGB code?

3) For the Fractional brownian motion, is this algorithm the result of combining several noise functions with each other? (I.e the output of a perlin noise function gets combined with another perlin noise function but with different parameters?

4) In essence, I'd love (if possible!) an explanation on how the image below gets generated from the fbm fractal. (In the hopes it makes the click that I'm missing*)

• You really need to step back and follow accidental's examples one step at a time, right now it's like you just walked into a grocery store and looking at all the shelves are wondering how a pizza is made from all those boxes =) You can only make good pizza once you know what's inside the boxes. Byte56's answer is a good place to start, at the lowest levels of just what noise functions produce. Jun 18, 2013 at 17:28

## 1 Answer

1) The gradient function returns a field of values, when those values are mapped

0->1 == White->Black

you get something like the following:

Further explanation is given in the article you linked:

So here we are mapping the line segment (0,1)->(0,0) to the gradient. This sets the gradient to lie between the Y=1 and Y=0 areas of the function.

Basically, what this gives us are some values we can use to manipulate the noise we get, to better fit what we expect from land. Since black is "nothing" and white is "solid", adding and/or multiplying the above gradient to any noise we get will ensure the world is (mostly) "solid" at the bottom and "nothing" at the top.

2) Yes, those values are mapped as the gradient image above. How should you interpret them? Ideally the noise values would return values from 0 to 1. Then, you'll pick some cut off point, like .5, and everything larger than that value is empty space and everything smaller than it is solid (or vise versa, it doesn't really matter as long as you are consistent). Now when you're building your world, if it's Terraria style, you'd sample the noise at discrete intervals. Each sample would tell you the value of the noise at that position. That value will be determined as solid or not, so you decide if you want to put a tile there based on the noise value.

3) ANL describes fBm with:

Fractals are a special type of combiner that combine up to 20 noise sources using fractal methods pioneered by Perlin, Musgrave, and friends.

So yes, your interpretation is correct enough to get you what you need from the library.

4) It's really a process of combining that gradient (with turbulence) with some noise. The description in the site you linked does a decent job at it:

Anywhere that the above image is black represents -0.25, anywhere that is white represents 0.25. So whereever the fractal is the darkest black, the corresponding point in the ground function is distorted "downward" by 0.25. (0.25 represents 1/4 of the screen.) Since one point might be distorted a little bit, and another point above it in space might be distorted more, this results in the possibility of overhangs and floating islands.