How to approach procedural planets

I have an idea on how procedural generation of convincing and realistic planets might be done, however, I still lack the skill necessary to put it into practice. My idea has a few downsides, but I believe someone more knowledgeable than me might be able to come up with a solution. One of the problems is that the planets would not be dynamic, meaning that over millions of years, they would not change whatsoever (regarding things like erosion and tectonics). Now to the idea itself.

The Star
First, we will start with the star in the middle of our solar system. The system would simply pick a random type of star (O, B, A, F, G, K, M) from an array. If I am not mistaken, this would affect quite a lot, actually - the size of the star, its ā€œenergy outputā€ (which would affect the temperatures on the planet and the distance of the planet from the star, among others) and even the prevailing wavelength of light (which would affect the color of plants, but thatā€™s not our main concern now).
The Planet
Similarly to what weā€™ve done with our star, weā€™re also going to more or less randomly pick the planetā€™s diameter, the tilt of its axis and the speed of rotation a) around its own axis and b) around the star. The diameter could affect for example the size and quantity of the moons, which would affect the tidal forces. The speed of rotation around the star would affect the length of the local year, along with the tilt of its axis affecting seasons. The speed of rotation around its own axis would not only determine the length of the day (duh), but also the trade winds formation (this will be very important later).
Terrain
The terrain generation would utilize several layers of perlin noise (3 I suppose). Overlaying the perlin noise like this generates more realistic shapes, which is explained here. Getting the settings of the perlin noise such as the frequency and the amplitude right would be a lengthy process regarding programming, I suppose, but definitely worth it. Another thing that might be an obstacle would be projecting the perlin noise on a sphere well and seamlessly, without an apparent ā€œedgeā€. But as I said, there is definitely going to be someone more knowledgeable than me who will be able to tackle this issue.
Temperature
Now that we have a height map, we are able to calculate an average temperature anywhere on the map. The lower the latitude, the higher the temperature, the higher the amplitude, the lower the temperature. Longitude does not affect the temperature. The ā€œbase valueā€ that will be getting lower or higher depending on the place on the map is based on the sun.
Trade Winds
Trade winds are based on the speed at which the planet spins; the faster the spins, the shorter the trade winds, therefore there is more of them. They affect the atmospheric pressure, which affects the frequency and the quantity of rain. They will be one of the factors in calculating the humidity. Also, if we wanna be lazy we can skip this part and use the Earthā€™s trade winds as a template.
Humidity
Humidity has three main factors, one of which (the pressure) weā€™ve already talked about. Second factor is the distance from a body of water against the direction of the trade winds (so if the trade winds blow from east to west on that given place, we are looking for the closest body of water in the eastern direction). This is because the trade winds ā€œcarryā€ the humidity from above these bodies of water onto the land. Third factor that affect humidity is whether there is a rain shadow (leeward sides of mountains). Mountain ranges are a very important factor in creating dry areas, therefore deserts.
Climate
Finally, with all of the information we have gathered, we can assign a biome to each place on the map using our parameters (temperature and humidity, basically). As you can guess, a place with extremely low humidity and extremely high temperatures would be a desert, an area with low temperatures and high humidity would be a snowy taiga. You get the point.
Final touches
After generating all the biomes, we can spice the terrain up even more. Where the climate is appropriate, rivers will be added by simply picking a random place somewhere relatively high and by always looking for a lower place, they will either enter the ocean or end up in a dead end creating a lake. We can also add glacial lakes where appropriate. Things like that might seem like tiny details, but will create a terrain that is convincing, realistic, but most importantly, a t m o s p h e r i c.

As I said, this system has some downsides. One of them is the fact that it disregards geological history completely. Another downside is the fact that itā€™s not dynamic and wonā€™t change at all over the course of million years.
Also, as a bonus Iā€™d like to mention is that we can use the same system we used for trade winds for oceanic currents, creating even oceanic biomes, which then can be converted into a patch map for the microbial stage. Which would be cool.
I assume the planet would generate when starting a new game, so the initial loading screen would be a bit longer, but on the other hand there would be less loading time when transitioning to 3D, as the terrain would be generated already. (Is this how it works, right?). Also, were it done later, it couldnā€™t be used for the patch map.
Also, a lot of people seem to like the idea of being able to slightly tweak the planet they will play on. This would be absolutely possible here, The players could chose any parameters from the Star and Planet section.

As always, I would love to hear your feedback, criticism, ideas for improvement, perhaps even a solution for the geological problem. Thank you for reading, have a good one!
Also, Iā€™m at work which means proofreading will be done at home, so donā€™t be surprised if thereā€™s like 20 edits, thank you, sorry.

7 Likes

I wonder if thereā€™s open source code to do most of this climatological stuff.

Hereā€™s a tutorial on generating terrain for a spherical planet.

I think it should be noted here that some of these random selections need to be heavily weighted. For example, 3/4 of all stars are M-class, and each class up is progressively rarer. Thereā€™s some special considerations as well, like close (habitable) orbits around M stars creating enough tidal forces to completely stop any planetary rotation.

3 Likes

That would surely save a lot of work, however, I donā€™t know about anything.

Nice! So getting the perlin onto a sphere is dealt with!

Thatā€™s something I havenā€™t considered, but should definitely be included! Thank you for bringing that up, since I havenā€™t thought of that.

If there isnā€™t open source code for climatology out there, which I would find surprising given the general proclivity of researchers for making things available, the dev team could try reaching out to people whoā€™ve implemented similar things in other video games. Tarn Adams comes to mind, as Dwarf Fortress world generation does most of this stuff.

2 Likes

Iā€™ve found the exact opposite to be true in reading a ton of papers as material for my thesis. Almost none of them include any kind of source code, though by googling I was able to find the source code for 2 of the around 40 papers I looked at. And most of that code was updated a decade ago and it didnā€™t compile anymore. So in my experience researchers are really stingy in providing a working implementation that they used to get their results, instead they want you to somehow recreate their software from their brief explanation.

This is a very nice post. I was thinking of writing basically the same thing today ha ha :slight_smile:

1 Like

Thatā€™s true actually, I donā€™t think Iā€™ve ever read a paper with source code attached. I take back that general statement.

So Iā€™ve just taken a look at this piece of code of yours and I am absolutely amazed. Youā€™ve put incomprehensibly more thought and effort into just the two first topics (Star and Planet) than I have into this whole post and it shows. And as you said yourself, I think that this piece of code might be very much usable even for the late stages. Be it now the procedural patch maps, the color of the chloroplast based on the wavelength, later even the color of the sky and so on. Again, Iā€™m amazed and I cannot wait to see this project of yours progress! Great job!

5 Likes

All of those words and numbers frighten me. Programmers scare me. Stay away. Iā€™m armed with a bachelors degree in freaking the :belgium: out.

3 Likes

Awesome thanks for the econcouragement Zahyyy. Iā€™m hopeful I can figure out how to implement it in a nice way, would be good to put that code to good use :slight_smile:

1 Like

Avagadro? I thought it was Avogadroā€¦

Yeah youā€™re quite right :slight_smile:

1 Like

Just a quick question - how far are you planning to go with this? Are you planning on creating the entire procedural planet generator? If thereā€™s any way I could help, let me know. I can try to come up with a formula to calculate the temperature change based on latitude and other factors, do some research on the topic and so on. Iā€™ve actually really enjoyed reading on about this kind of stuff and Iā€™ll be more than happy to continue doing that. So, if you need something researched while you work on something else, let me know! :slightly_smiling_face:

Ok yeah there is one question I was wondering about.

So say we compute an average temperature for a planet, for example the earth is approx 14c. From that how do we work out what the temperature of the different patches should be? Depth and latitude could be used in the calculations.

So for example if the earth is 14c on average then maybe a coastal patch at mid latitude should be 14 too, however the deep ocean will be different and so will patches at high latitudes etc.

If you want to work on that it would be helpful :slight_smile: Doesnā€™t have to be super precise either.

The things I mentioned mostly work just for terrestrial biomes, as the temperatures of the aquatic biomes is mostly affected by the temperature of the oceanic currents in that place. They work similarly to the trade winds, just a bit more chaotic (donā€™t know that much about them yet, all I know is that the warm currents from the equator flow towards the poles and the cold ones from the poles flow towards the equator, very simply said). As for the temperature, Iā€™ve found some details, which we can simplify a bit (we can always check by calculating for Earth and see how off we were). Here they are in a very brief fashion.

Altitude

If thereā€™s no snow (or rain) falling from the sky and youā€™re not in a cloud, then the temperature decreases by about 5.4Ā°F for every 1,000 feet up you go in elevation. In mathematical speak that is 9.8Ā°C per 1,000 meters. However, if youā€™re in a cloud, or it is snowing/raining, the temperature decreases by about 3.3Ā°F for every 1,000 feet up you go in elevation. Thus meaning itā€™s a change of 6Ā°C per 1,000 meters.
Source

The rate of decrease of temperature with elevation is known as the adiabatic lapse rate, which is approximately 9.8 Ā°C per kilometer (or 5.4 Ā°F (āˆ’14.8 Ā°C) per 1000 feet) of altitude.
The water vapor condenses (forming clouds), and releases heat, which changes the lapse rate from the dry adiabatic lapse rate to the moist adiabatic lapse rate (5.5 Ā°C per kilometer or 3 Ā°F (āˆ’16 Ā°C) per 1000 feet. As an average, the International Civil Aviation Organization (ICAO) defines an international standard atmosphere (ISA) with a temperature lapse rate of 6.49 Ā°C per kilometer (3.56 Ā°F per 1,000 feet). The actual lapse rate can vary by altitude and by location.
Source

Also a little chart.

In my opinion, the base value should be 9.8Ā°C/Km, as accounting for the water vapor in the air not only seems a bit of an overkill to me, but also would fall into the section of weather, not climate. HOWEVER, Iā€™m worried that this is the case only for the Earthā€™s atmosphere and Iā€™ll have to find a way to figure this out for other atmospheres. My assumption would be something along the lines of thermal conductivity, but again, weā€™ll need something to back up that assumption and work out the numbers for custom scenarios.

a l s o

Thereā€™s this piece of trivia that seems too specific to be accounted for and again, deals with the weather rather than the climate, but I feel like I should mention it.

Lapse rate occurs during cold, winter nights when the sky is clear and the air is dry. On nights like these, the heat from Earthā€™s surface radiates and cools faster than atmospheric air. The warmer surface heat then also warms the low-lying (low-altitude) atmospheric air which then rises rapidly into the upper atmosphere (think: because warm air rises and cool air sinks).
Source

Latitude

The change of temperature in different latitudes is caused by the angle at which is the given point facing the star. HOWEVER ā€œThere is no constant rate of fall in temperature with latitude.ā€ (*I will source this in a second)
Latitude is going to pose a greater problem. Here is the short version why:

Problems incoming

There is no constant rate of fall in temperature with latitude.

The rate varies greatly between tropics, temperate region and polar region.

This is because of the shape of the earth.

  • Tropics receive mostly direct sunā€™s rays.
  • Temperate regions receive slant sunā€™s rays.
  • Polar regions receive very slant sunā€™s rays.

The rate is low close to equator [Tropics]

  • The temperature difference between equator and tropics is only few Ā° C. Something like 5 Ā°C.
  • Rate = 5 Ā°C/23.5 degrees ~0.21 Ā°C/1 degree latitude

The rate is high in temperate regions

  • The temperature difference between Tropic of cancer and 40 degree N can be 10 Ā°C.
  • Rate = 10 Ā°C/16.5 degrees ~ 6 Ā°C/1 degree latitude
  • The temperature difference between 40 degree N and Arctic Circle can be more than 10 Ā°C.
  • Rate is ~ 6 Ā°C/1 degree latitude

The rate is very high in Polar Region

  • The temperature difference between Arctic Circle and North Pole can be greater than 20 Ā°C.
  • Rate = 20/23.5 =~8 Ā°C/1 degree latitude

Also, the rate varies greatly between the corresponding latitudes of Northern Hemisphere and Southern Hemisphere.

  • This is because of varying degree of land and sea area.
  • The rate is low in Southern Hemisphere because of the vast oceans which act as moderators.

Also, the rate varies with seasons.
Source

Speaking of whichā€¦

HOW COULD HAVE I FORGOTTEN

At least there is this article, that contains at least some mean values for the different seasons and such.

Here they are

The apparent mean annual near-surface lapse rate is āˆ’4.8 Ā°C /km and the latitudinal effect is āˆ’0.87 Ā°C /Ā°latitude.

In summer, the altitude influences the temperature variations more significantly with a July lapse rate of -4.3Ā°C /km and the effect of latitude is only āˆ’0.28Ā°C /Ā°latitude.

In winter, the reverse happens. The temperature decrease is mainly due to the increase in latitude. The mean January lapse rate is āˆ’5.0Ā°C /km, while the effect of latitude is āˆ’1.51Ā°C /Ā°latitude.

So, in short, latitude is not going to be a pleasant thing. We have to find out how the angle at which the rays hit (and thus the planetary axis tilt) affect the temperature losses and then weā€™ll be hopefully be able to figure out how that changes the temperature with latitude. Also, we have to account for the oceans acting as moderators, which I have completely forgotten about.

In short, the altitude might not be that hard to solve, but the latitudeā€¦ oh, the latitude. Meanwhile I can take a look at the oceanic currents and learn something about them, maybe Iā€™ll think of something regarding the latitude in the process, but I kinda doubt that.
Thank you for reading!

4 Likes

Ah very nice, looks like good research. If itā€™s ok with you it would be nice to summarise more. Maybe a bullet point section at the top or just less info.

-9.8c/km altitude sounds fine.

Re latitude I think probably a cosine function like this will fit relatively well. The x axis is degrees north and the y axis is average temp. Do you have some average temperatures for different latitudes?

Overall great work :+1:

1 Like

Thank you! And I will try to keep it brief next time, providing some sources to whomever would like to know the reasoning behind the exact numbers.
Also

I have to go to school now, but Iā€™ve already found some links, so once Iā€™m back, I will just extract all the info from them. You can expect an update to this post today.
Edit:
First we will divide the planet into some geographical climate zones using the planetā€™s tilt.
For torrid (tropical), the boundaries are equal to the axial tilt (on Earth thatā€™s approx. 23.5Ā°) on each side from the equator.
The polar circles are located at the latitude 90Ā° minus the axial tilt, or in case of the Earth approx. 66.5Ā°.
Anything in between is the temperate zone.
The next update I will do is the actual temperatures for these zones. I will try to keep them as brief as possible.
I wanted to keep this first update very brief, but I was not able to write in in bullet points so that I would convey the info well and I think itā€™s important to know how to calculate the boundaries of the zones.

1 Like

No rush, I think the stuff you are doing is cool.

I think probably we could work on a planet with no axial tilt in a first approximation, Thrive has a complicated relationship with seasons ha ha. Very interesting point about the location of the polar circles though, didnā€™t know that.

Re decline in temperature vs altitude I think maybe -9.8c might be a bit high. For example Everest is 8,800m so with that value it would be be 86.24c less than the temperature at sea level which is a bit much. I think itā€™s actually -17c compared to 20-30c at sea level or something like that. However -9.8c is probably relatively close.

2 Likes

I sadly still donā€™t have a definite answer for the latitude question, as thereā€™s quite a lot of variables and Iā€™m not sure to what extend do they influence each other. I will try to come up with something.

That will change a lot of things. The torrid zone will be a single line identical to the equator and the polar circles will be single points on each pole. Which means that the entire planet will be a huge temperate zone. But I guess that for the very first approximation itā€™s alright.

Thatā€™s an interesting point and I will try to find out why thatā€™s the case. This is exactly why I said this:

I will try to look into it and see whereā€™s the issue. However Iā€™m not sure when that will be, as my uni started already and I have to look after my girlfriendā€™s cats for a few days. However, right now Iā€™m at work and itā€™s sort of a slower day, therefore I have plenty time for reading and trying to figure out some solution.

1 Like

I am not sure it would be so simple. I think the temperature difference between the poles and the equator is largely due to the angle of the ground relative to the sun. So at the equator the ground is flat and totally aligned with the sun, so it gets a lot of heat, at the poles the land is angled away from the sun and so gets a lot less heat.

I think this means on a planet without tilt you would still have a temperature difference and the poles would still be colder. Though I am no expert for sure.

Re uni and stuff no problem, go at any speed you like :slight_smile: