IGNITE THE CORE: Plate Tectonics in Roblox! | Hex Planets Dev Blog II

Hi there!

I’m Daftcube, and this is the (long-awaited) second installment of the Hex Planets Dev Blog series, where I attempt to leverage computer science, procedural generation, and what I’ve learned about Earth Sciences to generate believable hexagonal planets!

Last time, I explained how hex spheres could be derived from icospheres. Well, we have hex spheres, but they’re pretty flat and boring. In this part, we are going to generate terrain for the planet by building a (very simple) simulation of how actual planets create their geography: plate tectonics. Slamming large masses of rock together sounds much more exciting. Let’s do that!

“Just Use Perlin Noise Bro”

While I’m mainly creating this planet generator for fun, I do potentially want to use the planet generator for a future game idea. Thus, I really want the generated planets’ geography to be meaningful and interesting. There should be oceans to sail across, mountains to climb, rivers to traverse, and vast flat areas to develop.

Perlin noise is considered the go-to way for folks to create randomly generated terrain. Perlin noise is a biased random number generator that creates fields of smoothly interpolated values. You can imagine if you mapped the below image to a terrain, where lighter means more altitude, you would get rolling hills.


(Source: Wikipedia)


(Source: Scratchapixel)

And perlin noise alone does generate patterns that can make for some functioning terrain. It’s easy, powerful, and it works. This leads to a lot of developers in this forum echoing variations of “Just use perlin noise, bro,” a whole lot.

But, plain perlin noise terrain is not believable terrain.

Planets and landscapes are not just covered by repeating patterns of rolling hills; they have continents separated by expansive oceans and split with towering mountain ranges in very particular spots. They have bays, river basins, and more.

This is something that actually really bugs me. People who just use math.noise to generate a bumpy plane are not generating terrain; they are generating a bumpy plane. Some folks do better by layering different octaves of perlin noise to get more irregular terrain, but the result is the same: a pattern of repeating but irregular hills. Once you’ve see it once, you’ve seen it all.

In order to achieve believable terrain, you need to take a stab at simulating the actual processes that make terrain what it is here on Earth.

So how do we generate believable terrain on a planetary scale?

What are Plate Tectonics and How Does Plate Tectonics Affect Geography?

Our planet is actually a giant reactor; the interior heat in the core of the Earth comes from radioactive decay of heavier elements that “differentiated” into the core during the Earth’s early life. Plate Tectonics is a theory that explains how the surface of our planet is partitioned into several tectonic plates that are moved, created, and destroyed via the intense heat and thermal forces that are exerted from under the surface.

There are two types of plates: continental plates and oceanic plates. There is a lot of nuance between them, but a suitable oversimplification is that oceanic plates are thinner than continental plates (hence why they are covered in water.)

Large geographic features are created when adjacent plates of different types interact in different ways.

Addendum I: It's not this simple.

Like any modern science, plate tectonics has a very large amount of complexity. I’m not trying to simulate everything; only just enough to create beautiful and interesting planets. If there are any geologists or other folks in the geosciences who might be cringing at my oversimplifications, I am sorry!

Divergent Plate Boundaries

Divergent plate boundaries are where adjacent plates drift apart. Most divergent plate boundaries are under the ocean, where they form ridges as hot rock rises from under the surface to create new terrain.

The most evident divergent boundary on Earth is the Mid-Atlantic Ridge.

While ridges are created, the net-movement of the plates generally results in a rift filled with water. See the Red Sea Rift, where the African and Arabian plates diverge, creating a deep rift that the Red Sea occupies.

Convergent Plate Boundaries

Convergent plate boundaries are where adjacent plates collide. When an oceanic and continental plate converge, the oceanic plate is often forced under the thicker continental plate. As the oceanic plate moves under the continental plate, it forms a deep trench in the ocean while pushing the edge of the continental plate upwards.

The sum of these movements is a deep oceanic trench followed by a large mountain range. A good example can be found on the west coast of South America.

When two continental plates converge, the result is a much larger and taller mountain range. See the Himalayas:

Turning Up the Heat: Defining Tectonic Plates and Boundaries

Before we can slam continents together, we first need to assign tiles to continents and solve for their continental borders.

To do this, I utilized a simple fill algorithm that picks random “seed” points on the sphere, and then expand until they hit another region. To keep regions less uniform, I added a random probability of not filling a hex each iteration.

BreadthFirstFillAnim

Some of the more keen-eyed of you will notice that this is just a breadth-first traversal algorithm. Breadth-first traversal is often taught before more complex pathfinding algorithms like A* in pathfinding applications. As you can see, there are many other uses for such an algorithm. Here’s an example of breadth-first traversal for use in pathfinding (source).

687474703a2f2f7265732e636c6f7564696e6172792e636f6d2f647172326d656a68632f696d6167652f75706c6f61642f76313530313336303734362f6266735f7373776d657a2e676966

Because our algorithm stops its fill operation when it runs out of empty tiles, modifying the algorithm to define edges is a pretty easy change. All that was required was a routine in the breadth-first traversal inner loop. The next picture shows continents with their border tiles highlighted.

tectonicPlateBorders

With our tectonic plates and boundaries defined, all that is left is to assign which plates are continental and which are oceanic. I achieved this through a simple random selection at first, and then upgraded to a system that randomly assigns plates based on a configuration.

Smashing Continents

I started with a system that randomly defined a direction of movement for each plate. This worked, and the visualization for the plate movements is pretty cool to look at.

However, this system produced fairly small boundaries. On Earth, diverging boundaries tend to be really long. For example, the Mid-Atlantic Ridge spans across almost half of the planet. So, I tried another approach where I defined plate boundaries first and then solved for the plates’ movements. In the following picture, diverging boundaries are marked with red and white arrows.

This system was looking closer to what I was aiming for, but I still liked how the first approach generated unique and chaotic plates. In my third iteration, I combined the two approaches to get the best of both worlds.

Once that was done, we need to evaluate whether each tectonic boundary was a converging boundary (plates colliding together) or a diverging boundary (plates separating). This was achieved using a simple vector function that projected the incoming force vector from one of the plates upon the edge of the boundary.

The following visualization shows the stress of tectonic boundaries. Tiles with lighter colors represent areas under high stress from plates smashing into each other, whereas darker areas represent where new land is being created by diverging boundaries.

Raising Mountains from Molehills: Altitude Map

Now that we have plate and boundary identities, we can derive the actual terrain deformation. In general, we should expect converging plates of like types to push colliding terrain upwards, whereas colliding plates of different types should subduct under one another.

Using a bit of trig, I put together a few functions that represent the terrain deformation at a boundary. In these functions, their domain of [-1, 1] represents both a tile’s distance from the boundary normalized onto a scale of 0-1 and which plate the tile is on, while their range of [-1,1] represents a scaling factor applied to the terrain at the given point. The above function is the deformation function for two converging continental plates; I am still tweaking the deformation functions for plate subduction.

Applying these functions to the terrain, we get some pretty cool results! The above image has the terrain with the tectonic movement overlay enabled. See how mountains are created where plates collide?

Results!

Here are some more cool results! There are still some scaling artifacts to fix (see black tiles) and parameters to tweak to get it just right, but overall I really like how this ended up looking even in its current state.

Because of tectonic activity, we can even get these cool island chains that reflect Pacific island chains on planet Earth!

Next Steps: Global Hydrology and Climate Model

Altitude and height only makes up a tiny portion of our experiences with geography. Landscapes don’t just have terrain, they have trees, rivers, and more.

The main determining factor of what a given part of a planet will look like is its climate. The next part of this project is going to tackle generating a realtime weather and climate model that simulates oceanic evaporation, precipitation, rain shadows, and more! Stay tuned!

Acknowledgements

My good friend and Applied Mathematics major DarkInfernoDrago , who continues to help tremendously with this project so far.

Hex planets have been done in the past. Experilous’s blog was a great resource, and while I did take different routes to achieving the same things, their writeup certainly informed my decisions. I hope my contributions built upon the subject!

The National Oceanic and Atmospheric Administration has a bunch of online resources on plate tectonics, specifically around undersea divergent boundaries, that helped give me an overview of the topic.

UC Davis’s open source textbook for GEL 56 provided lots of insights about plate tectonics. While I chose to simplify plate tectonics in my simulation, it provided a lot of useful guidance.

Google Earth for the images of Earth.

My PHYS 13: Life in the Universe course covered a lot of cool stuff about plate tectonics. Did you kow that plate tectonics might actually be a precondition for life to develop on a planet? Volcanism from active geology creates hydrothermal vents under the ocean, which are hypothesized to be the most likely place where life first evolved.

46 Likes

This is more of a geography lesson than a showcase… It’s AWESOME!

4 Likes

Is this open source? This looks like an interesting idea.

2 Likes