Skip to content

robertoost/RNGalaxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RNGalaxy 🌍🌑🌟🌞🚀

A procedural tectonic planet simulator.

image

Getting Started

  • Have Unity installed
  • Open the TectonicPlanetGenerator scene in the _scenes folder.
  • Run the scene, the settings will appear in play mode.

planet-gif

Enjoy!

Libraries and Assets used

I created a custom class in HalfEdgeMapper.cs that converts the convex hull from MICH and prepares it for the Delaunay3DToVoronoi algorithm from HCG. I also altered the Delaunay3DToVoronoi algorithm from that same package in order to link voronoi cells to their neighbors. The code for that can be found in the Delaunay3DToVoronoiTile.cs file. This resulted in a significant increase in performance. The following screenshot is for the generation of a 10.000 point convex hull from before the changes, and after.

image

Planet Generation

First, to get a uniform distribution of vertices for our sphere mesh, we generate a number of fibonacci points.

image

Then we find the convex hull of those points using MIConvexHull, and turn it into a sphere mesh using a method from HCG. I used a simple editor script to save a sphere with 30.000 fibonacci points so this step wouldn't have to be repeated during runtime.

image

In order to determine how we want to deform the mesh, we need to figure out where all the tectonic plates are. Again, we start of with a (smaller) number of fibonacci points.

image

And we follow this up by another convex hull

image

That convex hull is then used as input for the (altered) Voronoi Diagram algorithm from Habrador's Computational Geometry.

image

Our altered implementation allows us to find the neighbors of each tile, so we run a basic flood-fill to divide the Voronoi cells over the tectonic plates.

image

Finally, we give tiles at colliding plate boundaries a higher elevation value. For now, plate collisions are just randomly determined, with a low chance of oceanic-continental collisions and a higher chance of inter-continental ones. A KD-tree then lets us assign every vertex of the sphere mesh to a tile in the Voronoi diagram, after which we can raise or lower vertices according to their tectonic plate type. Vertices on oceanic tiles get lowered, while those on continental tiles get raised. A small amount of Perlin noise is then applied to vertices on every continental tile, after which another layer of Perlin noise gets applied across colliding plate boundary tiles. This gives us mountain ranges in places where you'd expect them to be.

image

Inspired by