Wednesday, September 10, 2014

A Geology Simulator for Game Worlds


THE STATE OF THE ART IN SANDBOX WORLD GENERATION

Unless you've been living under a rock for the last several years, I'm sure you've at least heard of the game Minecraft (and if you have been living under a rock, don't worry: you've been getting a very similar experience). 

The game uses a procedurally generated 3D world of blocks. You run around freely in a world that looks like the one below (default Minecraft) and dig and rearrange blocks to build things, such as the luxurious dirt hovel I put together especially for this blog post.

(Terrain generator by Markus "Notch" Persson)

(Built by yours truly! I also made this, by the way.)

I played minecraft for several years, as part of a server full of 20-40 year old nerds (the Voxelbox). We were not terribly impressed by the default gameplay, controls, or creative options. However, we did recognize an excellent core concept and a very modifiable set of bones to the game. We went about making a variety of tools to ease the creative process, allowing of course infinite free blocks, building from a distance, boolean shape logic, smoothing operations over thousands of blocks at a time, etc. Basically, the goal was 3D multiplayer photoshop. We eventually ended up being able to make landscapes like this:

or


BUT CAN I PLAY IN IT?

As nice as these end up looking (for a voxel engine), they doesn't really function as anything more than essentially a 3D painting on the wall. What if we still want to play the actual game?
  • The custom landscaping is only a thin veneer for looks. You could never play an actual game on this landscape that involved any sort of digging under the surface. It's all just solid gray down there.
  • It still takes hours of hand sculpting to make a section of land like this. It's fine for a proscribed experience like Skyrim, but not procedural games.
  • They're made by fantasy artists, not people who actually know anything about geology (or biology), so these scenes still tend to lack a lot of realism even at the surface, something a mining sandbox game should probably care about.
What if we just forget it when we want to play the game, and use the vanilla terrain generator? Well, even though Minecraft does a somewhat decent job of procedural surface terrain, its underground situation is just plain terrible. When you cut open the world, it's little more than a random jumble of uniform gray "stone" and caves and such. Clearly this has no geological realism to it:


Considering that the game involves spending a huge amount of your time underground--you know, mining--this becomes a serious drawback of game design.  Other games, like Dwarf Fortress also heavily focus on 3D procedural worlds. Dwarf fortress does a better job of realism, including some layers and stone types in somewhat reasonable locations:

(Terrain engine compliments of Tarn Adams)

...But we are still looking at completely flat, fairly random jumbles of rock types, mostly shallow, rounded, boring mountains, perfectly straight vertical volcanoes/tubes pasted abruptly into the landscape with only 3 feet of obsidian around them, and no correspondence to any broader geological history, other than putting the broadest categories of rock in roughly the right order.

A significant improvement is needed. I plan to attempt this by making a terrain generator that simulates actual geology, rather than faking an end product with simple fractals like these games do. If successful, this should exceed the realism, variety, and gameplay richness of the current leading games in the sandbox genre for world generation, both above and below ground.



TO MAKE A REALISTIC GEOLOGY ENGINE FOR GAME WORLDS


I am planning on implementing the following features for a geology simulator:
  • Proper plate tectonic-based continental history. Actual world plates will move around in a simulated history, collide, subduct, join together, break apart again, etc., forming realistic mountain ranges and continental shapes and compositions.
  • Bouyancy of plates causing bending, uplift, and fault lines.
  • Rock strata that curve in 3D when appropriate, for example when plates crumple together.
  • All continents come from somewhere. The world begins as all oceanic plates, and any continent can trace its history back to simulated volcanism, uplift, etc.
  • Realistic volcanism, with volcanoes of different types appropriately existing along corresponding plate boundaries. 
  • Magma is modeled underground and may not reach the surface, instead bubbling up in intrusive plutons that solidify into granite for example.
  • Metamorphism occurs from actual simulated pressure or heat from geological events.
  • Erosion follows (simplified) watercourses, weather patterns, and frost wedging.
  • Different rock types weather differently, leading to certain interesting and realistic features like Yosemite's Half Dome.
  • A rough simulation of life as it is relevant to geological history at first (for iron oxidation, mass extinction coal and oil layers, limestone formation, etc.), as well as more detailed climate and biome types added at the very end of the simulation.

The goal is to get cross sections that look more like the below image, with obvious geological features like this old, solidified lava tube, volcanic cone, sedimentary rocks filling in above over time, and the oldest rock strata down below pushed apart into curved blisters when the ancient magma forced its way between them:


(pixelated version: this is lower resolution than would be used)


NEXT UP IN THIS PROJECT

I'll lay out my plans for the basic framework of the world (and of the program, written in C++), including the main data storage types, the shape of the planet, and some other high level planning.

Later on, I'll dive into large scale plate tectonics by themselves as the first major benchmark to get working.

2 comments: