Wednesday, February 20, 2019

Tinkering with coastlines

I'm pretty pleased with how the coastlines have turned out, for the most part. But we need more variety.

I've already integrated one way of adding variety, which is to have a global "roughness" map. This is just yet another world-sized fractal. It influences the roughness of the diamond-square algorithm used to create the regional terrain. The higher the roughness at that tile, the more the algorithm will offset the values it assigns to points. That means that, among other things, the coasts will look a little wilder in "rougher" areas.

Also, landfills aren't used anywhere that sea ice is present, to make those coastlines look a bit rougher. The landfills tend to make for a slightly smoother appearance.

We need more though. One feature we currently lack is barrier islands. UW is quite capable of generating islands at both the global and regional levels, but barrier islands are distinctive in that they are very thin, lie close to the coasts, and mirror the coast.

The thing with barrier islands is that although they are quite common, they tend to cluster along particular coastlines. They are much more common along coasts that have low tidal range, that is, where there is little height difference between low and high tide. Tidal range, in turn, is affected by how exposed the coast is to the wider sea. More sheltered coasts - e.g. along Mediterranean-style inland seas - have smaller tidal range than coasts that face the open ocean.

Calculating tidal range properly would be pretty nightmarish, but fortunately it's not too hard to get a rough approximation that is good enough to make a vaguely plausible distinction between areas that are likely to have lots of barrier islands and those that aren't. On the global map, we take each coastal cell in turn. We then "cast" in all eight directions away from that cell - that is, we look along imaginary lines in all of these directions. For each one, we keep going until we hit land, and remember how long the line got. Then we add all eight of those numbers together. The higher the total, the more exposed the coast is and the higher its tidal range.

Barrier islands are too small to show on the global map, of course, so they only appear on the regional map. Drawing them is pernickety but fairly straightforward. It's a matter of finding the coastline on the tile, then copying it a couple of cells out to sea, with occasional breaks in the copy and occasional links to the land. The tricky bit is ensuring that we don't accidentally create sections of sea that are entirely enclosed by land, so we have to keep track of whether the lagoon (the area of sea between the island and the mainland) at each point is open to the sea or not.

This results in tiles that look like this:

 

 

And in regional maps that look like this:


They're hard to see as they're only one pixel across, but they're there.

Another feature we can add for more variety is glaciation effects. Wherever there are (or have been) glaciers, you tend to get very jagged coastlines with lots of fjords and little islands. Think Norway, of course, or Chile, or the west coast of Scotland. A fairly easy way to get a vaguely reasonable imitation of this, that looks nice though doubtless wouldn't be remotely convincing to a glaciologist, is simply to extend the mountains into the sea. So at the global level, we go over the coastlines. If we find any that are below a certain temperature, and that have mountains along them (of whatever height - remember that "mountains" might be fairly low hills), we add extra ridges sticking out into neighbouring sea cells, without adding any land below them. These don't show on the global map, and these cells are still considered sea rather than land. At the regional level, these mountains are drawn, and they give the effect of jagged coasts with lots of islands:



It's not perfect, but I still like to think Slartibartfast would approve.

1 comment: