Thursday, November 17, 2022

Weird worlds

Suppose we want a planet that looks something like what Mars might look like if it had water and life. Such a world has no tectonic activity, so there are no continental plates and no mountain ranges like there are on Earth. How do we make interesting terrain?

The obvious place to begin is with the trusty diamond-square algorithm, which, like the more widely-used Perlin Noise, can give us a randomised height map of this kind:


Stick in some sea below a certain elevation and we get this:


We've seen maps of this kind plenty of times already, of course, and we've also seen why they're not really suitable for world maps. There isn't proper structure to them - land and sea (and different elevations in general) are spread more or less evenly throughout the world.

Well, in fact that's not completely true - you can see on the map above that there's an area of ocean just left of centre - and this is because my diamond-square fractals are rather more complicated than usual. The parameters by which the elevation may be changed vary throughout the map, giving it a bit more variety than you would usually find in such images. If we increase this effect, we get areas where the image is more blurry:


That adds some variety, but it doesn't really make for a realistic map. Luckily there are more techniques at our disposal. One of the simplest but most effective is domain warping. I used this previously in Undiscovered Worlds to create noise at the local level, but subsequently got rid of it in favour of a more effective method for that purpose. But now let's bring it back! Briefly, we create three fractals: one as the source image, one to represent X-axis warping, and one to represent Y-axis warping. Each point on the map is then taken from the corresponding point on the source image, but displaced according to the other two fractals. We can easily control the strength of the warp by multiplying the two warp fractals by a constant.

Applying this to the last fractal shown above, with strength=20, we get this:


Strength=40:


And strength=80:


This is starting to look pleasingly weird! Note in particular how this technique creates ridges and valleys as it pulls the image about. This could make for interestingly alien-looking terrain.

We can also do another warp on it after the first is finished. Here's what happens if we do a warp of strength=80 and then another one of strength=60:


Even weirder! This effect is probably best used at relatively low strength, but by varying both this and the original warp we can get a variety of interesting terrain that doesn't look like the same old noise.

Another technique is to exaggerate the difference between peaks and valleys. If we read the elevation as varying between 0.0 and 1.0, and simply multiply each point's elevation by itself, we can do this easily. This effectively lowers all of the elevations, but the lower an elevation is to start with, the more it is lowered, causing slopes to be exaggerated. If we do this to the 80-strength single-warped image, we get this:


There's one more step we can take, which is to create a fractal with a very low level of detail, like this:


We can then multiply everything in the terrain by a fractal like this, thus forcing the appearance of large-scale areas of relatively high or relatively low elevation. Not only that, but we can use a similar technique on all of the effects we've tried, to vary their strength throughout the map. That can give more variation across the world. Here's the end result:

Here's part of it enlarged, so you can see the gnarliness in more detail:

I think that's a decent start for an alien-style terrain without too much effort.

One other thing needs to be considered, and that's the ocean. Using a mask to reduce some parts of the map, and also squaring the elevations to get more sharply defined peaks, tend to produce maps that are mostly sea. There's nothing wrong with that in itself, of course, and it's what we'd want if we were making Earthlike maps, but with these ones we don't want them all to be like that. So we'll lower the sea level by random amounts as well. That means we can get worlds with smaller seas, or that are mostly land, like Titan.

For our Earthlike worlds, we use a simple flood fill routine to identify the largest body of water in the map and then turn any separate bodies into land, because we want to have a single ocean. But this wouldn't be appropriate for these more alien worlds with less water, where there could easily be multiple separate seas. However, we don't want really small seas, which will always form when you declare any point on a fractal that's below a certain elevation to be water - as you can see in the last image above, in fact. That does seem unrealistic, and too obviously caused by over-reliance on fractals. So we do want to remove seas that are below a certain size, without necessarily having just a single ocean.

We can randomise what the size threshold is, for different worlds. One side effect of this is that if the size threshold is large, the algorithm may remove all sea altogether, resulting in large expanses of mostly flat plains that contrast with the high land from the fractals. I think this gives a nicely lunar sort of effect:

So what happens if we turn the climates back on? I had to do yet more work on the climate model to allow it to handle worlds without any sea. Briefly, some rain can still fall on such worlds, though not much, and mostly where the land slopes; again, think of Titan, which has no oceans - only methane lakes covering a relatively small proportion of its surface - but which does have methane rain and even rivers flowing into its lakes.

With the climate turned back on, we can get some interesting results. For one thing, the large areas of high land that this new generation method creates tend to lead to extensive snowy regions even in equatorial latitudes (on normal temperature settings). Consider this medium-sized world:

Here, an immense system of linked lowland plains winds around and between areas of towering highlands. The relief map looks like this:

The highlands are uniformly frozen, even though this world has an average temperature only 3°C lower than Earth's, while the lowlands - which are still fairly highly elevated - are frozen in the higher latitudes but warmer elsewhere. Most of this world that isn't frozen or tundra is either hot or cold desert, as you can see from the climate map:


But pockets of rainfall exist, mostly around the steep transitions between highlands and lowlands (even enough for some small patches of rainforest). As result, there are rivers, which flow into a number of saltwater lakes:


If you compare the rivers map with the elevation or relief maps, you'll see that some of these rivers are winding their way a tremendously long distance through the lowland system before ending in a lake (or disappearing off the top or bottom of the map, which is allowable in normal worlds but looks rather weird here, so that will need to be dealt with). Despite their length, the arid nature of the world means these rivers are only modest in size. Here are a couple of the larger salt lakes, near where a series of cliffs leads up to the frozen highlands:

And here is a patch of rainforest along the edge of another part of the highlands:

As is probably evident, I think this is a pretty interesting world. It's very different from the Earthlike worlds that UW has been generating to date, but it's not simply a map of random noise either. It's a plausible-seeming alien planet with meaningful large-scale geographical features, and one can imagine the kinds of civilisations that might exist in these strange conditions.

However, the complete lack of hills and mountains does mean that the regional maps look pretty uniform much of the time. Although the landscapes are weird, they look a bit bland compared to others that UW can produce, and there are even some dreaded grid artefacts making themselves known. So we need to think about what new kinds of smaller-scale features might be found on worlds of this kind, and how to make the regional maps look a little more interesting.

No comments:

Post a Comment