Friday, February 1, 2019

Basic continents

Rather than trying to mimic global terrain with fractals, it seems one might be better off thinking about how global terrain actually forms, and modelling that. That would be plate tectonics, and there's yet another whole school of landscape generation based around that idea. Carl Davidson's Tectonics.js, for example, will simulate the movement of tectonic plates in your browser, allowing you to watch continents crashing into each other and raising mountain ranges.

I'm not going to do that, because it's really difficult. However, I can have a go at creating a terrain that looks like it's come about from the action of tectonic plates, at least to a certain extent. That means thinking in terms of continents and the sorts of shapes they come in, and in terms of mountains and how they relate to continents.

This method took a lot of refining. Initially I tried making continents out of blobs pasted together. The computer would stick some blobs together and bung them on the map. Repeat this a few times, and you have sort-of continents. Then I put mountains on top of them. These were ridges that wandered across the land, sometimes branching off, and I placed them randomly on the grounds that, in the real world, mountain ranges seem to appear pretty much anywhere (sometimes in the middle of continents, sometimes on the edge, etc.). These mountains looked pretty good until the time came to work on the regional maps, and I realised I'd completely miscalculated the scale. What looked like nice mountain ranges on the global map were unworkable on the regional map, where they could be hundreds of kilometres wide (not long!), with a single ridge in the middle! Obviously real mountain ranges on Earth don't look like that, although perhaps there are planets where they do. (Olympus Mons, on Mars, is a volcano rather than part of a mountain range, but it too has a very, very wide area with a very shallow slope up.)

Given the scale of the global map - one pixel being 32 km across - any given ridge couldn't straddle more than one pixel (though it could stretch along several). Most mountain ranges consist of many ridges running parallel to each other. That means that I don't have the level of detail available to show ridges and valleys on the global map.

I decided that the best way to represent a mountain range is by a grid, with each square holding two values. One value is the height of the mountains in that square, expressed as a proportion of the total range height. The other value contains information about which way the ridges are running in that tile, and which neighbouring tiles are connected to this one by ridges.

Here is an illustration:


Here we see the grid for a simple mountain range. Each square here corresponds to a single pixel on the global map. The greyscale indicates the height of the mountains in that square, and the yellow lines indicate the direction of the ridges. You can see that the ridges can merge and branch with each other.

The information about the ridges will be important when we come to the regional map level, when UW will use this information to design its own ridges that roughly follow these outlines but with their own unique form; but all of this will be irrelevant to the global map because it's too large-scale. For our purposes at the moment, only the heights in each square matter.

Now it's a simple matter to use grids like this to make mountain ranges on the global map. UW just chooses a location for the range, chooses a height for the given range, and then raises all the relevant pixels by the appropriate amount.

(In fact UW maintains two global heightmaps - one with the mountains and one without. We'll see why when we get to the regional map level.)

Mountain ranges need land to sit on, of course, so we'll handle that with some simple templates too. In fact I'm using just two land templates:


These are ready-made and UW simply loads them in. They are randomly rotated and flipped, and pasted under each pixel that's got a mountain on it. Even though there are only two templates, the process of transforming and combining them in this way creates a wide variety of land shapes.

The result is something like this:


That's a start. We can improve things by introducing the concept of chains. A chain is simply a line of mountain ranges, one after the other, going in the same direction, though they may swerve. That results in this:


That isn't bad for a sort of island. The linking of different ranges into longer chains itself creates more variety, as one chain will differ greatly from another.

Mountain ranges (and chains) sometimes run down the edge of continents. This is where an ocean plate meets a continental plate and subducts under it, throwing up the mountains. Think of the Andes in South America:


We can easily reproduce this (without having to worry about the actual plates) simply by extending the land out perpendicular to the direction of the mountain chain. All we have to do is paste more land templates in the relevant direction, to a random length:


That's getting somewhere - this could almost be a believable continent as it is.

Now if we make lots of these and scatter them across the map, we get this:


Where these "continents" touch each other, we get variations where the mountains are not necessarily just along one coast, but may appear in the middle of land masses as well - as if formed by the collision of two continental plates.

Now we want to vary things up a bit. The key to interesting map generation, I think, is combining different techniques. This means that different parts of the map have different appearances, which is more interesting than the same sorts of shapes appearing everywhere. So in that spirit, I use some more simple land templates, like the ones shown before, but more of them (ten in fact). What UW does now is simply paste lots of these (possibly rotated and flipped) onto the map. If the centre of the template is over sea, then UW turns the whole area covered by the template into sea. If it's over land, then the whole area gets turned into land. This means that "bites" get taken out parts of the existing land masses and also added on to other parts.

This shakes things up a fair bit:


Now in addition to the smaller continents based around mountain chains, we have these larger continents that have grown off them from the addition of the templates. None of the shapes of the individual templates can be made out here, of course - they're clustered over each other completely to create new shapes.

There are a couple more elements to add for this stage. First, let's throw in a load more mountain chains - but these ones will only have land right at their base. They may appear in the sea (in which case they will form long islands - think Japan) or they may straddle the land (in which case they will form long peninsulas - think Italy):



And one more round of mountains. This time we'll make the chains shorter and partially submerge the mountains, creating island chains:



Now we're starting to get somewhere, but it's not ideal. Some of these continents are bloated and rather weird-looking, and although some of the mountain ranges look good where they are, some look a bit odd - and there are large areas that could do with additional mountains, as well as more variation in height generally. But this is just the first part of our global map creation process. As I said above, the important thing is to combine different methods to create variety in the map. We'll do that in the next post to bash this into better shape.

No comments:

Post a Comment