Entry 34 - More About Rivers & Plant Models - March 13, 2016

More About Rivers
I'm a pretty huge fan of the KISS principle but the rather simple approach to just choose random points to spawn rivers and to modify them a bit with sine has a few drawbacks. The worst ones I came across so far: Rivers may collide with each other Rivers may collide with themselves

The crazy stuff going on with the rivers in the above picture is not cool!

I need to improve my approach. One thought was to detect the shore and then let rivers flow from random points in the map to random shore points.

Shore Detection
Detecting the shore is actually super easy: Check all heights in the terrain array. If a height is below sea level, check the 4 direct neighbors of it (top, left, bottom, right) and see if at least one is above sea level. If this is the case it's a shore. Otherwise it's not. The green shore line in the picture is detected this way.

A* Pathfinding
I tried determining the perfect river path from the random land point to the random shore point with A*. I'm not happy with the results and also my A* is super slow because I'm using a pretty poor priority queue implementation. Overall A* seems to be a bit overkill. It would probably take most of the terrain generation time even with a highly optimized priority queue.

Using The Voronoi Data
I already used Delaunay triangulation to generate Voronoi polygons for the heightmap itself. It would be clever to generate the rivers based on the same data. That's actually what the Red Blob Games guy does. My map creation algorithm is based on that article. So this is what I'll try next to finally get some plausible random rivers.

More Models
Also here are two new basic models with hand painted textures.