Sunday, February 5, 2023

Mud and sand

Having grown up by the coast, I'm very aware of the need for a terrain generator to be able to handle different kinds of coastlines. So I wanted to try to include some in Undiscovered Worlds.

Since I currently live near the Bristol Channel I'm particularly aware of the importance of mud flats, so I had a go at incorporating those first. The basic idea depends on a feature that has been present in UW for a long time: inlets. The program removes land around river mouths, depending on factors such as the size of the river and the tidal range at that point. It occurred to me that it's easy to keep track of where these inlets have been created, and we can simply lay down mud flats around them - again based on factors such as the size of the river and the tidal range. Mud flats, of course, are represented by an array of bools within the region object.

At this point things got very complicated as I decided this would only make sense if we also kept track of how much silt every river is transporting. I wrote a new system to simulate this and got it mostly working, but annoyingly it wasn't quite right. This was a pain as the maps looked quite good with river colours varying from bright blue to dull mud, depending on their silt content, but the fact that sometimes this didn't work right (with small stretches of river inexplicably showing too much or too little silt) made it not really worth the effort - especially as it was largely a visual effect that didn't really make much difference to the world generation.

So after scrapping all that, I went back to the inlets. In this map, inlets are marked in magenta:


These are all river mouths where the program has cut away land to make it look like the rivers have eroded the coastline. Most are for very small rivers, but some are for larger ones.

Now we create a temporary array to hold silt levels. Going through the map tile by tile, we lay down silt levels on coastal cells that are within inlets. The levels of silt are determined by the size of the river and the tidal strength of the area. Then, we go through the map again and spread the silt out from these points, both inland and into the sea. Any cells that have a certain level of silt or higher are then turned into mud flats, which also involves setting their height to 1m above sea level, and possibly creating some saltwater wetlands nearby too.

Only a few inlets actually have enough tidal strength to generate mud flats big enough to show on the map - bearing in mind that each pixel is a kilometre, so the mud flats have to be quite extensive to show up. Here is a region that has quite a lot of them:


And on the relief map, they blend in fairly subtly with the wetlands around them:



We can also add mud flats to river deltas, too:

Now we want nicer beaches too! Namely, sandy beaches and also shingle ones. We can make these in exactly the same way. With the beaches, though, the tidal range is more important than river size, so we tend to get mud flats around large rivers and sand or shingle around small ones. And where mud flats tend to spread inland along the rivers, beaches tend to spread along the coast. Finally, we set it so that mud, sand, and shingle can all mix with each other, making for varied coastlines.

The resulting effect is quite subtle, because again only really large beaches can be seen at this scale. Here, you can see a few spots of yellow or brown along the coast where there is enough sand or shingle to make a large beach:


There might not seem much point adding such minor features, but one of the new planetary variables is lunar gravity. Worlds with weak lunar gravity have small tidal variation, and relatively few mud flats and beaches. But worlds with strong lunar gravity can have extreme tides, with correspondingly extensive beaches and mud flats:

There are a couple more tweaks we can add. First, mud flats get a chance to generate barrier islands along the ocean-facing edge. This results in areas like the Wadden Sea, where a string of islands protects a large intertidal zone. Second, in tropical areas, mud flats (and salty/briny wetlands) get mangrove forests on them. You can see the darker green coastal areas here (the user can turn off this effect if desired):


So that's that for coastal zones, at least for now. The next job is to try to work out why all my coastlines have acquired far too many little craggy islands and get rid of most of them (they never used to look like that!). After that, I'll aim to release the updated version.

2 comments:

  1. For your extreme tides image: If this much sand and mud was showing, it must be low tide. In this case, all of those tiny green islands would be submerged at high tide, right? Then should they also be sand or mud?

    ReplyDelete
    Replies
    1. Yes, you'd think so. It could be that they're elevated enough not to get submerged, maybe? Luckily it's proving fairly easy to stop so many of them being generated, but I think it will make sense to add a function that turns small islands into beach or mud if the tidal strength is high enough.

      One problem with the images though is that there isn't really a way to distinguish between coasts where the tide is in and those where it is out - all beaches are shown all the time, which obviously is unrealistic if the maps were taken to be satellite images. But I think it's OK on a less-than-photorealistic map. I'll have a think about whether it might be possible to show different tidal states...

      Delete