Building an island

Building hills

So we start with an integer array of 50×50 that will represent the island heightmap. We start by filling the array with 0, then build a first hill :

choose a random radius for the hill (smaller enough to stay in the map, for example < 10)
choose the hill center inside the map at xh,yh (we want water all around the island so the hill should not cross the map borders)
for each cell x,y, calculate the hill height = radius*radius – ( x – xh )*( x – xh ) – (y – yh)*(y – yh);
if the hill height is positive, add it to the cell

Great ! This is what we get :

Now, build more hills… After 5 iterations :

After 20 iterations :

Give it a natural look

It takes shape, but still has an unnatural look. We could iterate a lot more (100 or 1000 hills) to get a really smooth landscape but this would take some time and don’t forget this is a low scale map, so we don’t need high quality. To reduce the visibility of the hill borders, we can blur the picture and/or add noise :

This is called Fractionnal Brownian Motion or fbm. Despite its scary name, it’s just a fractal sum of perlin noise textures. More information on perlin noise can be found starting with this link :

When we add the 20 hills texture and the fbm, we get the final island heightmap :

Now we replace the grayscale colors by an appropriate gradient (blue for water, brown for sand, green for grass, white for snow) :


No Comment.

Add Your Comment