Thursday, June 6, 2019

Delta blues

Most of the main landscape features that I was planning at the global and regional levels are now in Undiscovered Worlds. There's one big one left though: river deltas.

Deltas are caused where a river flows into a larger body of water (usually the sea), and where the river is slow-moving enough to deposit the silt that it's accumulated over its course. The silt is dumped in the sea and creates new land, with the river splitting up to go around it. Islands appear in the river and you get lots of wetlands. And obviously deltas are very striking seen from above:


So we want to try to replicate them in UW.

Now as we know, rivers in UW emerge from flow between cells. Any given land cell can receive flow from any of its eight neighbours. And it sends outgoing flow - calculated as the total of the incoming flows - to a single one of those neighbours, usually the lowest one. This is a perfectly reasonable way of modelling the usual flow of water over land, but it can't handle deltas, because these are points where rivers split up and send outgoing flow in more than one direction.

So what can we do? I spent much time thinking about this and decided: we need a whole new river array. This one will be just for delta branches. As with the normal river array, each cell will have a direction and flow volume (for both January and July). But they will run in reverse.

Here's how we calculate it. At the global level, we go through the mouths of all the rivers and work out how likely they are to have deltas. Basically, I assume that the probability of a delta appearing is a function of the tidal range of the river mouth, the size of the river, and the steepness of the terrain.

Once we have a river mouth that we want to deltafy, the next step is to find locations for the mouths of the delta branches. This is reasonably straightforward. We put these in the sea, next to the coast, like the endpoint of the river, but we displace them along a line (roughly) parallel to the coast. The result is something like this:




The white squares are the end points for the branches of the delta. Bear in mind that what we're doing right now is all at the global level - I've just marked them at the regional level because it's much easier to see there. Some of them are a little further out to sea than others, but that doesn't really matter because all rivers run into the sea to some degree and we just don't show those bits.

Now we choose a point a few cells upstream. This, the "origin point", will be the point at which the river turns into a delta.

Then we pretend that the branch mouths are actually the beginnings of rivers, flowing towards the origin point. So all we have to do is take each branch in turn and trace it from its mouth up to the origin point. Obviously we can't do this like normal rivers, going downhill. Instead, we aim for the origin point but allow some deviation along the way. If we hit one of the existing branches, we simply add this branch's flow to that of the existing branch and follow it up to the origin point, just as we would for a normal river that flows into another one. (The flow for each branch is easy to calculate - we just divide the flow of the original river by the number of branches.) The result is a network of branches flowing together and coalescing as they near the origin point - which looks, in reverse, exactly like a river splitting into branches which then split further as they near the coast.

We also reduce the flow of the river downstream from the origin point so it's the same size as the delta branches.

Finally, we flatten all the land on the delta branches, the reduced river, and surrounding cells so it's only slightly above sea level. (This was actually tricky to do as it led to the river in that area carving out great big estuaries on the regional map, which I don't want where deltas are meant to go. It was harder to stop it doing that than you'd think and eventually I gave up and put in another bodge to just raise all areas of sea near deltas to be above land.)

If we use white squares on the regional map to mark the tiles that contain delta branches, we now have this sort of thing:



There are a few annoying artefacts from the flattening, but overall this looks good - already we have shapes that look roughly like river deltas should.

So we've got the routes of our delta branches more or less sorted at the global level. Now it's just a matter (just! ha!) of drawing rivers on the regional map where these branches go. Basically, we treat the delta branches as an almost completely independent river system. That means that they don't deliberately interact with existing rivers passing through their tiles - they might run near them or even cross over them, for example. Ordinarily this would be anathema but we want that confused, jumbled look of a river delta where streams merge and split all over the place. The exception to this of course is at the origin point, where we want the delta branches to meet up with the main river so it looks like it's splitting into them. And as before, we treat them as if they're running from the sea to the origin point. We draw them on a separate delta map, and then when they're all done, we copy them onto the normal regional river map, reversing the flow directions as we do so so that they appear to be flowing towards the sea.

Needless to say, getting this working required a lot of jiggery pokery and dealing with wildly unexpected problems. But I'm quite pleased with the results (note the wetlands too):





As always, they're not perfect, and there's still a fair bit to do on smoothing out some of the code and correcting weird artefacts, but I think they look pleasingly chaotic and also quite varied in the patterns they trace.



4 comments:

  1. Wow. Those are beautiful. Very clever approach!

    ReplyDelete
    Replies
    1. Thank you! I must admit I didn't expect this approach to work as well as it did, so I'm quite happy about them.

      Delete
  2. I think those look pretty good/realistic. I have river deltas on the TODO list for Dragons Abound, so it's interesting to see how you tackled it!

    ReplyDelete
    Replies
    1. I'll definitely be interested to see how you deal with this one!

      Delete