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:
- Generating rivers from coastlines
- Generating elevation from rivers, part 1
- Generating elevation from rivers, part 2
- Sketching coastlines and mountain ranges
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.
Sketch ⯀mountain ridges or ⯀coastlines:
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.
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.
2 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:
The parameter controls the elevation exponent, which I often use to sharpen mountain peaks. The bitmap is used for the next section.
3 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.
(Update: the game was cancelled, but I was able to improve the rendering significantly, and some of this ended up in mapgen4 a year later.)
4 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.