Dev Blog

Hi, this is the Stranded III development blog (see also Forum Thread, Comment Thread).

Overview (114 Entries)

Entry 35 - Voronoi Powered Rivers, Bezier & Shell Model - March 20, 2016

Voronoi Powered Rivers
I'm now using the terrain Voronoi data also for the rivers.
This is what it looks like when random Voronoi edges are used for the river generation:
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen4_pre.jpg

> click to enlarge


Note that I also incorporated a blacklist to prevent the algorithm from using the same edges multiple times. This solves the issues from my previous blog entry (rivers colliding with themselves and other rivers).
Still room for improvement though. So what I did next is working with the terrain heights again. The following picture shows the adjusted algorithm which prefers edges with lower heights as successors:
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen5_pre.jpg

> click to enlarge


Not the worst result I saw so far but there's still a lot of stuff to take care of.
I'm generating pretty flat terrain areas with different heights. The current river approach would spawn the rivers alongside the cliffs and slopes between these areas. To avoid this I altered the algorithm to use the random Voronoi center points instead of the edges.
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen6_pre.jpg

> click to enlarge


A problem still present in this picture: The river ends are not blacklisted. They seem to continue in the sea but actually it's just other rivers coincidentally using the same center point.
Also they are obviously super cornered. That's not what rivers look like. Bézier to the rescue!
I use the code from Bézier Curves for your Games: A Tutorial for the Bézier path calculation. It's for 3D points but reducing it to 2D is trivial.

IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen7_pre.jpg

> click to enlarge


Much better! Next problem: Rivers can still collide with each other in some specific cases. This is due to the grid nature of the center points. It allows diagonal "x"-collisions of lines when adjacent (not blacklisted) pairs of points are connected with lines.

IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen8_pre.jpg

> click to enlarge


It's relatively easy to solve this problem: When scanning diagonal neighbors as potential river successor nodes, make sure that their diagonal neighbors aren't blacklisted either.
An additional improvement would be to blacklist the areas around a river after generating it so other rivers are not spawned too close to it.

I also started writing some code to dig the riverbed into the terrain. I'm basically lowering the terrain around the river line, using a simple distance check to define how much the height should be changed. This allows me to easily create rivers of any size.
The following screenshot is a bit cheated because the water in this river is actually from my sea water plane:
IMG:https://stuff.unrealsoftware.de/pics/s3dev/mapgen/rivergen9_pre.jpg

> click to enlarge


Later I'll have to create triangle strips to create the water surface for the river water.

What about lakes and waterfalls?
I read many comments regarding lakes and waterfalls. Both of these things are planned. In fact I already posted something about lakes in a very old dev blog entry. This was just about a map editor tool which filled pits with water by creating a water surface mesh but the same stuff can be used for the random map generation as well. There we just need another step which searches or forms a pit for the lake.

The plan for waterfalls is that they will be spawned as soon as the height difference in a river is large enough. For instance when a river is flowing down a cliff. I could even do automatic rapids for micro bumps in the riverbed. I didn't work on this yet.

Shell
Finally here's a quite stupid and random time lapse video where I try to create a shell model with Blender. With webcam picture in picture showing my hands. It's amazing!
> Click to watch on YouTube!

Disqus

blog comments powered by Disqus