Jump to content
  • Advertisement
Sign in to follow this  
vantubbe

Procedural Generation Relating to water

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!