24 Jul 2017

Table of Contents

Note: the /x/ series of posts on my site are mostly unpolished mini posts. I’m trying out a few different ideas for procedural map generation; this is one of them.

The past few mini projects were:

This week I’m going to glue these together (in a hacky way for now): sketch coastlines and mountain ranges, and see what rivers and elevation are generated.

The page may be a little flaky. I’m including the javascript from two separate projects and hacking them to work together. I’ll fix it up later but for now I just wanted to see if it worked at all.

#Sketch

Sketch mountain ridges or coastlines:

Noise:

The rivers will mostly follow the guidelines, but I have some randomness in there to allow rivers to cut through mountain ridges occasionally. That parameter will need to be tweaked eventually.

Crater lake image

Bonus feature: To make an interior lake, draw the lake as a coastline. By default the interior will be land. Draw inside the coastline with to make it a lake instead. Some of the algorithms work on non-island maps too. If you of the map you can make a crater lake.

#Export to elevation image

The idea behind sketching was that you’re drawing lines which are then mapped onto a mesh. If I keep the original lines, I can map them onto a higher resolution mesh. For this project, it was quicker to draw the elevations to a bitmap and then build a new mesh from the bitmap. Here’s the bitmap:

Sharp:

The parameter controls the elevation exponent, which I often use to sharpen mountain peaks. The bitmap is used for the next section.

#Generate detailed elevation

From two blog posts ago, I came up with some algorithms to carve canyons and ravines into the terrain. (This renderer may not work across platforms… still need to look into that)


Try changing the sharpness slider above and re-rendering.

It looks neat but I don’t know if we’re going to use it for our game.

#Next steps

This week was about a quick hack to combine the last few mini projects to see if everything would work together. It didn’t at first but I found many bugs and fixed them, and now it seems to work reasonably.

Now that I know these steps work together, the next step is biomes.

Also take a look at this page, which has a river algorithm that does a lot more than mine does: lakes, erosion, deposition, river deltas, water tables, snow, surface tension, capillary action. Cool! I didn’t try those algorithms; our game doesn’t need them.