I had another crack at the problem with which I ended the last post. It occurred to me that the problem came from the fact that the lake surface in the tile in question was higher than the elevation of the rivers would normally be in that tile (=tile height-constant). So I added a constraint to the lake generation in the global map generation phase, such that lakes will not extend onto tiles where that would be true. This had the following effect:
Yes, the poor lake's completely disappeared now. This is one of the things that make it hard to tell whether an action has actually solved the problem it's meant to deal with - it may change the map in other ways, removing the elements that were associated with the problem altogether, and making it impossible to tell whether that means the problem will never crop up again or merely that this particular offender has simply been wiped away. All I can do is keep my eye on other lakes and see whether anything like that issue appears again.
A cursory examination of other lakes doesn't reveal the same problem, but it does reveal another, superficially similar one. Here's another lake in this world:
The surface of this lake is 745m above sea level. Here is one of the rivers heading towards its southwestern corner:
This river enters the tile at the south at an elevation of 767m. It drops over the course of the tile until it reaches the cell that's highlighted in the image above, at which point it is at 748m. This is all fine, except that the next cell - the one on the northern edge of that tile - is 755m. Then it flows into the following tile:
The highlighted cell here is 763m! Then it flows downhill nicely until it flows into the lake (elevation 745m).
In our previous problem, we had rivers that (a) plunged down to sea level for no apparent reason, or (b) meandered up and down hill at random. We solved those problems (I think). Here, we have a river that flows downhill properly most of the time, but jumps up when it enters a tile containing lake.
I think that when the program is working out the elevation of the river in the first tile, it is calculating the target elevation (that is, the elevation of the river at the last cell it occupies in that tile) wrongly. It's calculating it as if the elevation of the river in the next tile will be at the surface height of the lake. This is something I made it do while trying to solve the problems in the previous post. (Yes, there quite a few measures I tried that I didn't even mention in that post.) I think it has resulted in this new bug now.
So I try reverting: now tiles that flow into tiles that border lakes calculate their river target elevation on the basis of the average elevation of the next tile (minus our constant for river erosion), not on the basis of the surface level of the lake.
Incredibly, this works. Now, the river in the first tile stays at 768m until the last cell in the tile, when it drops to 764m. In the next tile, it starts at 763m and drops gradually to 749m before entering the lake at 745m (as it originally did). Which is all believable!
This may be the first time I've encountered a horrible river elevation issue, worked out what the cause probably is, tried something to rectify it, and succeeded on the first attempt. It will almost certainly be the last, too. Still, we progress. There are still many problems. If you look at the map of this region that I posted above, you may notice that a tributary of the big river that flows out of the lake seems to disappear for a stretch and then reappear. This is because, for some reason, that river drops in volume for a tile - not by a vast amount, but enough to take it below the threshold of the size of river that is drawn in the relief map. Why does this happen? I have no idea. But I'm tackling the problems in order of seriousness, and I think that rivers that flow uphill are a bigger problem than rivers that shrink in size for a bit. Slowly, bit by agonising bit, the maps become gradually less immersion-breaking.
No comments:
Post a Comment