Monday, October 10, 2016

Procedural Plate Tectonics

Last time we covered noisy layering in order to make biomes. This was done relatively arbitrarily though and we saw weird biomes like tundras being in the middle of deserts. This is obviously something we don't want to happen so we need to make a better procedural algorithm to make biomes.

I've decided to take this whole thing a step further. Instead of using simplex noise to determine heights like we did last time, we're going to procedurally make plate tectonics. To those of you who don't remember 9th grad science, the Earths out shell is made of a serious of plates that move very very slowly. However, over millions of years this movement causes many landforms that we know today, like mountains! In theory, procedurally generating some plates and then simulating their movement could generate very interesting and realistic landmasses. 

So how do we go about generating plates? Well I thought of two different methods that could work. The first one is slightly more complicated. For this, we choose an arbitrary number of plates and a starting point. From there a neighboring block is chosen and added to the plate. This is then looped through all the plates until there are no more empty spaces. Let's take a look at the code quickly.

We can see from the code that we first keep track of all the empty spaces, then choose random distinct starting points for reach plate. Then we loop through each plate, get a random neighbor and try to add it to the plate list. This process is pretty slow and these take a while to generate. However, once it finishes and we colorize each plate, we get an image like the one below.
I had really high expectations for this algorithm to work and I was less than pleased with the results. We can see we get very long plates like the light-blue in the middle. I was hoping for a more "blobby" plate like actual Earth plates. While I'm sure this method could be modified to give more desirable results, it's still pretty slow so I decided a new approach.

Attempt two took a slightly different but similar approach. First I choose an arbitrary number of points to be the plate "centers." From there, I checked every point on the graph and colorized it based on the closest "tectonic center." The code for this is drastically easier to understand.

As you can see it's actually quite simple to do this. Just some simple loops and checking. ( It should be noted that this is NOT the best way to do this by any means. This is a brute force method. There are much better algorithms like Fortune's Algorithm that do this much faster than me. ) What this generates is called a Voronoi diagram where each point is colored based on its closest reference point.

When we run this we get a picture like below.
While this looks interesting, I'm still not 100% happy with how it will work for plates. For one, looking at a real map of plates, they do not have such straight lines. These are "blobbier" though which I am happy about.

Turns out making procedural plates is harder than I thought it would be. I may re-visit this or go with the Voronoi diagram, I've not decided yet. Either way, we will be combining this with many other procedural algorithms so this is just a starting place. We still have a long way to go!

As usual the code can be found here. Thanks for reading.

No comments:

Post a Comment