# How to procedurally generate Mountains that Looks more natural

My Terrain was looking a bit plain so to freshen it up a bit I decided to add mountains to the terrain generation. Unfortunately the Mountains don't look very natural with the surrounding terrain.

I generate the mountains currently by:

1.start at a random spot on the map that is above sea level

2.raise that to the highest point and have surrounding blocks staircase up to it using a radial noise pattern

3.move a certain number of blocks away and repeat until the mountain reaches the coast

here is the code for extra clarification:

void generateMountains()
{
//Find Starting Location
int startingX = Random.Range(0, grid.columns);
int startingY = Random.Range(0, grid.rows);
RidgedMultifractal noise = new RidgedMultifractal();
noise.Frequency = .01;
noise.OctaveCount = 8;

while (grid.FindTile(startingX, startingY).elevation < -3)
{
startingX = Random.Range(0, grid.columns);
startingY = Random.Range(0, grid.rows);
}
//createMiddle highest point
Grid.Tile middlePoint = grid.FindTile(startingX, startingY);

//how many mountainBlocks to be generated
while(middlePoint.elevation > SEALEVEL)
{
var tilesAroundMid = grid.getNeighborhood(middlePoint, false, 25);

for (int i = 0; i < tilesAroundMid.Count; i++)
{
//setting the distance away from mid
float distanceToCenter = Mathf.Sqrt(Mathf.Pow(middlePoint.x - tilesAroundMid[i].x, 2) + Mathf.Pow(middlePoint.y - tilesAroundMid[i].y, 2));

if (tilesAroundMid[i].elevation + Mathf.RoundToInt(((float)noise.GetValue(tilesAroundMid[i].x, tilesAroundMid[i].y, .1) * 10 - distanceToCenter) + 15) >= tilesAroundMid[i].elevation)
{
tilesAroundMid[i].elevation += Mathf.RoundToInt(((float)noise.GetValue(tilesAroundMid[i].x, tilesAroundMid[i].y, .1) *10 - distanceToCenter) + 15);
}
}
middlePoint = grid.FindTile(middlePoint.x + Random.Range(10,15), middlePoint.y + Random.Range(10,15));

}

}


How would I change my code so that the mountains generated looks more natural and realistic with the surrounding terrain?

• Check out Fractals. Mar 16, 2015 at 2:51
• or perlin noise Mar 16, 2015 at 7:12

## 2 Answers

I wouldn't seperate the mountain generation from the general terrain generation but combine them.

Today the usual approach to generating landscapes is using 2D or 3D noise functions like perlin or simplex. By combining several amplitudes and octaves you can add both general height (like mountains and valleys) and some detail. You'll probably need to experiment with the values for the number of different noises and their octave/amplitude values to a natural looking result.

2D noise might be fine for you since you basically get a heightmap which seems like what you're going for. 3D noise has the added benefit of being able to generate overhangs and caves which probably won't work out great in your case which looks like only 16 height levels.

Another and simpler approach to creating a realistic heightmap is called diamond-square in which you basically start a small grid with only 4 random heights at the corner and interpolate the gaps (with some random deviation) in a row of two-step rounds.

How are you making the differences in height on your more flat terrain? It looks like you've already got something along the lines of concentric rings going on so why not grab the center of one of the rings and push it up, push each ring around it up, and then radio noise between the smaller vertical distance of each ring?