cell voronoi

Nicolo’s World Generator

INTRODUCTION

Since quite a few people asked for a tutorial on my procedural world generator, here it is. To be honest I don’t know a lot about procedural generation, I am just wing it as I go, but I manage. The generator Is not yet fully done ,still missing what I call “populate” to add small landscape details, but here is what I got.

PS. In this tutorial I will not who any code, this tutorial is just to show how I’ve managed to create the worlds for my game, for I believe trying to explain how everything in code works would require too much time and would bore the life out of you.

THE IDEA:

The gist of my generator is a node graph system with delaunay triangulation and a modification of the voronoi diagram of the triangulation. 

HOW IT ALL WORKS:

  1. Firstly it adds random points in a confined space and triangulates them
  2. Then it add more points in specific positions to add detail
  3. It removes the points that confined the work space (the 4 outside points)
  4. Again it add more points to add detail
  5. After that I get the voronoi diagram and the shortest spanning three of the triangulation
  6. Finally I remove some of the cell of the voronoi diagram

With the voronoi diagram I then have a plane which I will use for the world surface.

Depending on how many starting points you use, or how many levels of detail you add the result vary.

 2D to 3D:

The diagram is only the first part of the problem, now to get it to show it as an actual island I take the voronoi diagram and transform it into a mesh, before I translated the code to C# for Unity I saved them to a OBJ file now I just make a Unity Mesh.

To do so I take every point in the diagram as a vertex and every cell as a face, then I get the outer edge of the mesh and extrude it downward multiple times to make the cliff. The outer edge is also used to make the fence, where every vertex is a post and every edge is the bar between the posts, and to later populate the cliff so to make it more interesting.

Tips:

  • Never try to make a world generator at 2 in the morning, it will take more than 2 hours.
  • If you want to make something procedurally generated Random is your friend.
  • Use a object oriented language, make objects for everything and keep reference of every point, edge and triangle, this way it’s easier to make the triangulation and later the voronoi diagram.
  • Be careful on the amount of points, edges, and triangles you have, it takes a lot of time to iterate through large lists and it’s not a good idea to make your player wait too much for your world to generate.

The generator is not yet complete, and in no way the definitive way to make procedurally generated worlds, there are other ways that might be easier to Implement, such as cellular automata, but I found that this method gave me the result I wanted.

I might do a part 2 later on once I finish to the “populate” part of the generator, but for now thanks for reading and have a good day

4

One of my favorite processes in HE_Mesh
1) Start with container mesh
2) Divide the container in Voronoi cells using a regular or irregular 3D arrangement of points
3) Randomly discard half of the cells, glue the remaining cells back together, fix non-manifold edges and vertices, keep largest connected submesh
4) Remove the boundary faces
5) Smooth the resulting surface
6) Shell the surface to give it some thickness