Render rivers in a grid.

Posted by Gabriel A. Zorrilla on Game Development See other posts from Game Development or by Gabriel A. Zorrilla
Published on 2011-06-29T16:02:09Z Indexed on 2011/06/29 16:31 UTC
Read the original article Hit count: 557

I have created a random height map and now i want to create rivers. I've made an algorithm based on a* to make rivers flow from peaks to sea and now i'm in the quest of figuring out an elegant algorithm to render them.

It's a 2D, square, mapgrid. The cells which the river pases has a simple integer value with this form :rivernumber && pointOrder. Ie: 10, 11, 12, 13, 14, 15, 16...1+N for the first river, 20,21,22,23...2+N for the second, etc. This is created in the map grid generation time and it's executed just once, when the world is generated.

I wanted to treat each river as a vector, but there is a problem, if the same river has branches (because i put some noise to generate branches), i can not just connect the points in order.

The second alternative is to generate a complex algorithm where analizes each point, checks if the next is not a branch, if so trigger another algorithm that take care of the branch then returns to the main river, etc. Very complex and inelegant.

Perhaps there is a solution in the world generation algorithm or in the river rendering algorithm that is commonly used in these cases and i'm not aware of.

Any tips? Thanks!!

© Game Development or respective owner

Related posts about algorithm

Related posts about procedural-generation