I am about to reenter one of the most difficult thinking challenges I have ever dealt with. The work I did in an earlier version of the game actually surprised me in how far I got. Now, I am going to have to repeat that, and afterwards, I'll have to go farther. We're talking about geology, the shaping of worlds.
What you see in the picture is the comparatively simple prelude to that. I have spent the last few days making craters work, and now, they look fairly good. You're looking at a star above a rocky crater world, not unlike Mercury. Not amazing by far, but good enough for me to accept for this version. Craters actually handle a lot of what you will find in space, since most planets have limited geological activity, but when things get more complicated, they get a lot more complicated...
Because it is a topic I have already done a fair bit of work on, I will be going deeper into geology than other topics. Basically, the word means "talking about the earth", as in the earth beneath our feet, not the planet Earth (geo = earth, logia = talking, explaining). But in daily terms, geology takes more interest in the wde variety of materials you might find the ground to made of, not just earth; sand, rock, clay, even lava and magma. Soil is studied more in boilogy, or the soil-specific field of 'pedology'. For our purposes, it's going to be mostly about rock, and the planet Earth.
What we know as the Earth is actually a tiny, tiny part of the planet. The solid surface is often described as "the skin of an apple", the apple meat inside being very different things (incidentally, yes, that's also how many scientists describe the atmosphere around the Earth; the solid surface and the air covering it (the 'atmosphere' we know is mainly the low 'toposphere') form roughly the same thickness of layers, each about 10 km thick). Beneath it, heat, mostly from decaying radioactive atoms trapped inside the Earth, helps keep the rocky masses of the planet in a semi-liquid state, often described as 'gum-like'. It moves about, slowly, because the hottest parts deep down rise up, forcing the cooler upper parts down, where they are then heated and in turn rise. This constant circulation of rocky material is called convection, and the flows of material up or down convection cells, or simply convection currents. Something similar is used to make lava lamps do their gooey job.
Deep down, about halfway to the center of the planet (the Earth has a radius of about 6000km, so we're a little over 3000km down now), we find the Earth's molten core. My apologies to hollow-earthers, but you're all a bunch of deluded morons. The core is made mainly of iron, because the biggest stars stopped fusing atoms when they reached iron, and scattered all that iron in their supernovae. The immense heat keeps the iron liquid as it spins around along with the rotation of the Earth, but inside the core is a solid second core; the pressure of all that rock and molten iron on top of it pressed the iron atoms together until, in defiance of the heat, they become solid iron. The liquid outer core and solid inner core do not spin exactly the same speed as the planet, though; the inner core spins a bit faster than the planet, and the outer core spins a bit slower. When you stand on the Earth, imagining the cores beneath you, the inner core would thus seem to spin a bit eastward (the Earth spins eastward, which is why the Sun rises in the east, and the inner core does the same, just faster), and the outer core seems to spin slowly westward (the Earth is spinning a bit faster, and thus seems to 'pass it by', making the outer core seem to go backward, i.e. spin westward). All this spinning makes the cores act like huge magnets, their component atoms spinning like electrons in coiled wires. This magnetic field makes up the Earth's magnetosphere, which is what magnets in compasses can detect. Also, it keeps particles from the Sun from scorching us, because those particles get magnetically sucked to the magnetic poles of the planet, where they either zip past us or crash into the atmosphere as aurora, like the Northern Lights.
Stuff like this seems very background-ish, but in a full space game, it really isn't. Without a magnetosphere, life has some hefty challenges, as dangerous particles keep beaming down on the surface, easily killing living cells. mars may have once lost a magnetosphere when its core slowed down, causing possible past life there to die out, at least on the surface. Sun particles blasting a planet can also change its surface chemistry, leaving atoms that would not otherwise be found there, millions every year, for millions of years.Electrical gear will be greatly affected, as might even weather. To create realistic planets, these contemplations are not the most important, but they are important, depending on the realism! But to us, a big part of their importance is in what other effects they have on a planet's development.
We already talked about molecules. Atoms snap together to form practically everything we see (except the light that lets us see it, ironically; that's made from photons, which atoms merely emit). So do they make rock, too? Yes. Rocks are basically oxygen and silicon atoms put together in huge grids, looking a bit like the hexagonal cells of beehives. Because the structure keeps being copied in all directions, it's called a crystal lattice. Rocks made mainly from silicon and oxygen are also called silicates. The purest kind, with only silicon and oxygen, in a perfect crystal lattice, is actually quartz, and the way the atoms are put together can be seen in the shape of the quartz, which hints at the hexagonal structure of the crystal lattice. Other crystal lattices found in rocks (any of which would be called a mineral by geologists, but not like the minerals you see in nutritional values on food) may have other atoms in the mix, such as aluminium (that is the correct spelling, thank you very much), magnesium and so on. Quartz with iron in it, for example, can become the purple amethyst, or the yellowish citrine, or with some magnesium, the green olivine. Other minerals have a broken up crystal structure, the hexagonal grid becomeing single or double chains, or even rings or scattered bits of silicon and oxygen held together by clinging to other atoms mixed in.
Today, those and other original minerals share the world with minerals from living creatures, now long dead. Shells and bones and such from tiny sea creatures have been crushed together to form such things as limestone on ancient sea floors, and then risen above ground through forces we will soon look at. Crystal structures have been altered by heat and pressure beneath the surface; rocks formed from molten rock cooling are called igneous rock, literally meaning "from fire", either intrusive igneous rocks (if they manage to cool while deep inside the planet, where the molten rock is called magma) or extrusive igneous rocks (if they cool after being spewed out as lava), while rock created from bits and pieces gathering in layers on the surface and being pressed together by massive rock layers over milions of years are known as seidmentary rock. If sedimentary rock gets heated greatly without completely melting, it hardens into metamorphic rock.
We can sometimes see the results of all this with our naked eyes. Different kinds of rock may end up in layers, after which the whole mass gets pushed up or has part of it scraped away over millions of years by water, weather or the like. In the end, we get walls of striped rock, each stripe its own kind of rock. And each rock is made of its own mix of minerals, which in turn give it a lot of different properties, the simplest of which include strength, durability against water, wind, acid, etc., weight, how it flakes (does it become sharp?), and so on. Next time you look at a stone slab, such as in an expensive kitchen table top, all those little bits of color are various minerals mixed by nature (or humans) to become that exact kind of stone.
On the big scale, things work differently. And then again, there are some similar points. Eons ago, when the planet was still a molten ball of lava (or magma, as we call it when it's not on the surface), the first solid bits of the surface we know today began to form. Two types of rock played the main roles: Basalt and granite. Basalt is very mafic, meaning it has a lot of magnesium and iron atoms in it. That makes it heavier than granite, making it likelier to sink into the depths of the molten rock again. But it also withstands heat a bit better, so basalt early on formed some solid 'ground' on the molten Earth, even if it was low ground and liekly to sink again. Granite is non-mafic (a.k.a. felsic) and thus lighter, but also easier to melt (basalt melts around 1100 Celsius, granite around 950), so it formed the higher layers. The first real land was probably the cratons, huge and mainly granite rocks floating about on the molten rock, just barely surviving. They bumped together and stuck together through molten rock on their surface, and new rock cooled on their edges or fell as dust and sprays of lava on them, becoming sedimentary rock over time. In the end, the cratons became large slabs of rock on top of the molten planet. And then, they began bumping into each other again. but rather than just sticking, these huge, slow, heavy plates, called tectonic plates, mashed each other's edge into new shapes, or simply bumped and shook the edges. Two plates grinding against each other without pushing too hard or pulling away will create such bad shaking that we see it as an earthquake. Plates moving away from one another (diverging) leave gaps that magma beneath can rush up through, while plates moving aginst each other (converging) force each other's edges up and down, creating mountain ranges (the process is called orogeny, if you were wondering). In some cases, typically when a low basalt plate meets a high granite plate, the upper plate edge rises as mountains, while the lower gets pushed down into the deep to melt again, a proces called subduction. Basalt plates typically form ocean floor, being low and all, while granite ones form continents. Other rock gets mixed in or layered on over time, of course.
The way tectonic plates shape the Earth have been studied for only some decades, because it took a long time for people to accept that the world was not just made as one piece, but as huge puzzle pieces that move too slow for us to truly see (except not really; in Iceland, two plates are pulling apart, ripping the island slowly in two. You can stick a rope into either side and leave it slack, only to find it taut hard a few months after, because the two sides are pulling apart. If you know your stuff, you can do similar observations on other plates). Since then, a lot of study has gone into simulating exactly how the features of the Earth's surface are formed and warped by these forces.
AS FOR THE GAME...
As stated, I am working with these things right now! I have simulated very basic tectonic land formations before, and soon will again. The principles of how these forces work are better known every day, and my main job is to translate them into math, and then game graphics. This is not, however, as easy as it sounds, even if it doesn't sound easy at all. But the principles are there, and that is half the battle.
What this kind of procedural generation does is add a sort of personality to the landscape. Regular procedural generation usually uses 'perlin noise' and fractal concepts, which just means it creates a pattern of randomness that it uses over and over again, at different scales, merging the results together. A bit like taking a photo of yourself and overlaying it with four smaller copies, then doing that again for each copy, and so on. This is why in many games, you can look at a landscape from a distance and get the distinct feeling that it has a repeating pattern. But more annoyingly than repeating patterns, it also means that everything is more or less just a fluent mix. Patches of mountain show up here and there and then plains or sea or something else takes over again. Mountain ranges, winding valleys, coastal cliffs and the like do not form well with this method, if at all. Traditional procedural generation is, to sum it up rather crudely, patches of bumps.
A simulation more true to the scientific principles described (and other principles not described) has a better chance of making the landscape distinct. You do not just find a patch of tall bumps (or dips, if the bumps are turned on their head, which is a common way to make quick canyons and valleys), instead you find ranges of mountains running across the landscape where plates meet (the Alps, the Himalayas), likely not far from a coastline that they roughly follow (the Rocky Mountains, the Andes). They play a role in the shape of the world, but they also stretch. Patches of mountains are more like a blob, they rarely stretch out. Mountain ranges stretch. That's the difference between a parking lot and a highway; the highway stretches, the parking lot is just there.
The geochemistry is another interesting matter. In our last journey, we talked about how a 'chemistry engine' would allow new materials to be made in game, without the tacit approval of a game creator. The things are defined by how they get put together, not by what some designer wanted to exist. Geochemistry is the other side of the coin, the side where things are found. Remember those stripes on the side of cliffs, canyons, valleys and mountains? Those minerals are where we get a lot of our modern raw materials from. Red stripes (they are technically called bands, but googling 'rock band' is just not productive when doing geology) are usually iron oxide, as in rust, as in where we get some of our actual iron from. Good mineral ores are valuable in the modern market, and were valuable to those who knew how to use them in the past. Such minerals are used in everything from drywall to toothpaste, and when metal is extracted, in even more things. The aluminium (correct spelling!) in your car or aluminium foil comes from rock dug up from the ground (often bauxite). Most copper today comes from chalcopyrite, although cuprite is a way prettier rock. And you would not be reading this if nobody was extracting tons of silicon every year, of course!
For a game with a very limited scope, none of this has much value. For a single world that looks much like our own, a 'bumpy slab' of various mountains and simple valleys work great. In fact, few people notice that almost all big games use just that: A flat area with bumps and dips added semi-randomly. Unless everything is in buildings or cities, of course. But for variation, that is a risky method. No Man's Sky has gazillions of worlds.... or, as one critic put it, six worlds, which are mainly color swaps, and then tons of each, with a few hills looking different here and there. That's what the old method gives you: Blandness. Mountain ranges, coastlines, cascading canyons and other things made by tectonic activity and the differences in how quickly or slowly various rock gets worn away create real and interesting landscapes.
Oh, and one thing to ponder: If a world is so cold it is mostly made of ice or other frozen materials, the forces that shape rock will instead shape that ice, forming ice valleys, ice mountains, even ice volcanoes (yes, that is a thing) and rivers of chunky, semi-molten ice. Worlds made from other things will have other landscapes. Maybe a planet has such a massive iron core that molten iron runs like lava, forming islands and continents. Maybe the crystals are not ground down into bits of minerals, but amethysts rise from the ground to form true purple mountain majesty; caverns like that have already been found... on Earth. This would take ages to design on purpose. With good procedural generation and a clear grip of geochemistry and geophysics, it might just be yours far quicker.