# Procedural Generation Relating to water

This topic is 2553 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am a huge fan of JTippets and his articles describing procedure land generation. One thing that I don't believe he went over (maybe he did implictly and I'm just missing it) is how to get water into the picture. The issue that I have with it is how to make sure it is flat if against air, but yet conform to the land shape. I have been messing around with this for weeks and havn't been able to quite get the picture of how to do this. In similar fashion to how he does caves + top terrain (generate both and then multiply them together) I would imagine you could generate a water "map" based on the caves+land values, and then multiply them together. The devil is in the details though. Any help would be greatly appreciated!

##### Share on other sites

I am a huge fan of JTippets and his articles describing procedure land generation. One thing that I don't believe he went over (maybe he did implictly and I'm just missing it) is how to get water into the picture. The issue that I have with it is how to make sure it is flat if against air, but yet conform to the land shape. I have been messing around with this for weeks and havn't been able to quite get the picture of how to do this. In similar fashion to how he does caves + top terrain (generate both and then multiply them together) I would imagine you could generate a water "map" based on the caves+land values, and then multiply them together. The devil is in the details though. Any help would be greatly appreciated!

The simple way to add water is to just say, that water fills the level up to an height of X. I.e. when generating a level with a height between 0-255, you could say, that the map is under water up to an level of 50. Many terrain engine work like this.

It gets more complex, when you want to add several layers of water i.e. rivers and waterfalls, in this case you need more elaborated algorithm/simulations to get it right.

##### Share on other sites
Hi,
It is also rather simple to write a flood filler to create lakes at various heights. In my lake system each lake object has starting point and grid size which are used when tracing the areas covered by the lake.

The grid size allows to make large lakes with fewer polygons and small lakes with smaller polygons in case they are surrounded only by thin land walls.

The flood fill algorithm requires the terrain height map and the water starting point (XY-position and Z-level) as input. If the position of a lake is changed, it is necessary to redo the flood fill, but this isn't a big deal. I'm able to move any lake practically in real time.

Cheers!

[EDIT] the benefits in these kinds of lakes vs. "water-plane at certain level" is flexibility and less-waste of fill rate

##### Share on other sites

Hi,
It is also rather simple to write a flood filler to create lakes at various heights. In my lake system each lake object has starting point and grid size which are used when tracing the areas covered by the lake.

The grid size allows to make large lakes with fewer polygons and small lakes with smaller polygons in case they are surrounded only by thin land walls.

The flood fill algorithm requires the terrain height map and the water starting point (XY-position and Z-level) as input. If the position of a lake is changed, it is necessary to redo the flood fill, but this isn't a big deal. I'm able to move any lake practically in real time.

Cheers!

[EDIT] the benefits in these kinds of lakes vs. "water-plane at certain level" is flexibility and less-waste of fill rate

That's not a bad idea, and it would lend itself to, like you said, updating the water should you need to move it. The issue is that I think this might get pretty expensive. My world is defined by a density function, func(x,y,z) -> returns a value that tells you about the world at that point. So I can't just define the surface of the water, I need to define all the points under the surface, up to the ground. Even for small bodies of water that could be a bit costly. That's why I'm hoping to be able to add onto the methods Tippets described, and be able to generate water as part of the land generation. The issue is of course the details of that. Thanks for the idea!

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013603
×