Sunday, January 30, 2022

Small update

I've been doing a fair bit of unglamorous bug squashing and general tinkering. Much of this is behind-the-scenes stuff that just makes the code work a bit better and hopefully crash less often, but there are also some visible effects, mostly at regional level:

  • Some river-related bugs have been removed. Plenty remain, naturally.
  • I made some additional tweaks to the climate simulation, to reduce the amount of desert slightly.
  • A long time ago I implemented canyons, which work by creating wide areas of the map where the land is raised up higher than usual around the river valleys. Somehow the effect of these was much reduced when I ported the project over to its current form. I've now made it much stronger and more noticeable.
  • In addition, some of the smoothing routines applied to the regional terrain tended to widen canyons in an unpredictable way which made them look weird. I've stopped that, so now river valleys really look like river valleys.
  • I worked out why - as noted in the previous post - some coastlines had acquired extravagant islands (it was to do with changes to how the sea bed is generated), and toned it down so it only happens sometimes.
  • I also removed a tendency to create lakes right by coastlines, noticeable in (among others) the last image here.
Here are some pictures, in which you can see the river valleys more clearly in some areas, as well as varied coastlines. I think the texture of the land is looking pretty nice now:





And as a bonus, here's an epic river system:


Tuesday, January 4, 2022

Grids revisited

A while ago I posted about a problem with grid-like artefacts cropping up. These are an unavoidable side-effect of relying so heavily on the diamond-square algorithm for generating detail on the regional map: that algorithm is known for a tendency to look a bit grid-like.

Back then I came up with a rather elaborate solution for this problem which involve blending the terrain with a warped fractal. However, while this did eliminate the artefacts, I found that it tended to flatten the terrain too much and remove much of its texture, so I turned it off. That still leaves the artefacts problem.

Here's an uncommonly severe example:


While it doesn't usually look quite this bad, even occasional examples as horrible as this are unacceptable. I've found that this problem usually occurs in coastal areas where there are lots of rivers and a few ranges of hills or low mountains, so this is a typical sort of map to have this problem.

It occurred to me that rather than messing about with adding interference to the terrain to try to mask the grids, there could be a much simpler method. For each tile, I take a random point on each side. I then mark out a circle (with a radius equal to the width of a tile) centred on each point. Then I simply rotate that circle by a random amount. The rotated circle is progressively blended into the original (the closer to the centre it is, the more strongly it's the rotated version; the closer to the edge, the more strongly it's the original). And that's pretty much it. This is done after the basic land elevation is generated, but before the hills and mountains are added, so they aren't affected. Also, for obvious reasons we don't alter any points that are on - or bordering - rivers or lakes, or sea.

Much to my surprise, this not only worked exactly as planned the very first time I tried it but yields what I think are really nice textures for the maps. Here's what the area above looks like with this technique in place:

This is clearly a big improvement - the grid-like features of the original are almost entirely obliterated, but without making the terrain flatter and less interesting. Instead, the texture is more finely grained, while still keeping the general areas of high and low ground in place. (And don't ask me where all those islands have come from - I must have made some other change that caused those, but I can't think what.)

Here are a couple more maps to show off this general look:




As you can see, the new effect is most noticeable in the green areas with high rainfall and more rivers, but it shades nicely into the more arid regions and mountainous areas which are both sometimes associated with the more terraced look you can see in the last two images (and which is applied after the rotation effect). So we've got a bit of variety in the appearance of our maps, which is always good.