A procedural tectonic planet simulator.
- Have Unity installed
- Open the TectonicPlanetGenerator scene in the _scenes folder.
- Run the scene, the settings will appear in play mode.
Enjoy!
- Fibonacci sampling from: (https://github.com/OcarinhaOfTime/SpherePlacement)
- KD-Tree from (https://github.com/viliwonka/KDTree)
- Sci-fi GUI from (https://assetstore.unity.com/packages/2d/gui/sci-fi-gui-skin-15606)
- Perlin noise from (https://github.com/keijiro/PerlinNoise)
- Habrador's Computational Geometry (HCG) (https://github.com/Habrador/Computational-geometry)
- MIConvexHull (MICH) (https://designengrlab.github.io/MIConvexHull/)
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.
First, to get a uniform distribution of vertices for our sphere mesh, we generate a number of fibonacci points.
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.
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.
And we follow this up by another convex hull
That convex hull is then used as input for the (altered) Voronoi Diagram algorithm from Habrador's Computational Geometry.
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.
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.