dandrino/terrain-erosion-3-ways

Request for Info : Water?

Closed this issue · 4 comments

Hi, first off I was able to get your examples to run on windows without any issues, no real surprise there I suppose.

I am just wondering if it is possible to maintain the water in the model so I can have rivers and lakes pre-built? I don't expect you to do this for me but is it stored in there somewhere? I am using the river network code.

Just to clarify, are you asking if it is possible to generate the river network and terrain heightmap given a set of lakes (land-enclosed bodies of water) and river network priors?

For lakes, the short answer is yes, and the long answer is it depends. There are several types of lakes you have to take into consideration:

  • Endorheic basin lakes - These are landlocked lakes with no outlet. These are would be fairly straightforward to implement. For predefined lakes, you just include them in the water mask you pass to the code. For generated lakes, you would have to basically do another pass of river network generation given local heightmap minima as the seed for the river networks instead of the water mask (I almost included this in the demo, but decided to pass for simplicity). Example endorheic basin lake: https://en.wikipedia.org/wiki/Mono_Lake

  • Lakes with outlets (incl. reservoirs) - These are basically lakes with an outlet (note that very few lakes have more than one outlet). These are more complicated, since they basically form by water flowing into a local height minimum, filing up, and overflowing to continue downstream. The code as-is doesn't handle these well since it assumes that rivers follow a monotonically changing height along their path.

For pre-defined rivers, could you clarify what you are thinking? Would you basically have a pre-formed section of the river network? If so, you could basically prepopulate the priority queue in compute_river_network with your river network edges, just giving them a weighting of less than -1 to guarantee that they are included in the final river network ("naturally"-generated edge weights in the priority queue are never less than -1)

Idk if this is what you are asking for, but let me know if you have any more questions.

Not quite but I appreciate the response.

I am wondering if you have already calculated the rivers and lakes. From what I can understand of the code, that is the whole point of the river network module. It builds rivers and then traces their effect on the terrain. I am not sure if lakes are captured as a by product of that process but I assume they are there too. The water has to go somewhere so presumably it acculuates in lakes.

I think it might already be in your code. I can see a water variable with a list of floats which seem to correspond to points on the map. If I can figure out how to export it, would the higher water values be where the rivers and lakes are? Is there a reason you don't draw the water when the hillside code runs and builds the png?

Lakes and oceans are given as a prior via the land argument to compute_river_network, which is a boolean mask indicating whether a point is land or water (True = land, False = water). Currently the demo code (main in river_network.py) uses fbm filtering to create this mask, and it also eliminates lakes (but I don't remember why I did that).

In terms of rendering rivers, the hillshading code takes 2d arrays as inputs and produces a 2d rendered image as an output. The river network is basically a giant set of arbitrary 2d line segments. It's possible to include the river network in the hillshading code, but it would require rasterizing those 2d line segments, which I didn't end up doing.

So that's what the land mask does. I had been pondering that. It makes sense.

I think I have it working via the simulation code. I was able to get to the water just a little more readily and have it rendering out to a map. I will see how it goes but I think I have what I need for now.