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.

2 comments:

  1. Is there a version I could try out? It looks amazing!

    ReplyDelete
    Replies
    1. Thank you! I'll be releasing something pretty soon as I'm basically just stamping out bugs now.

      Delete