Procedural planets

Posted On 31 Aug, 2015
Feat

Sorry guys, this next update is mostly visual improvements. Lets chat a bit about planets.

My workflow

I have to wear a lot of hats other than programmer, so when I am wearing the programmer hat I try to be as efficient as I can. Usually that means my programming work is loosely scheduled and tends to be a bit chaotic because I switch into programmer mode to accomplish something that interests me. Afterwards I stay in programmer mode long enough to do the thing I was really supposed to do, but it takes me a bit of time to get there.

This patch started as bug fixes for last patch, except one of the bugs was very elusive and I spent a bit longer chasing it. Then I had a bunch of real life stuff that switched me out of programmer mode for a few days. When I came back, Jan had some fun new things to put in, and that’s what had my interest until recently. In other words, I tried to fix some bugs and accidentally spent multiple weeks putting in cool new stuff. Oops.

One of the huge overhauls to existing systems introduced in the next patch will be…

 

Planets!

If you were the type that likes eye candy, and maybe if you remember what our system was like before we changed the layout of the world map, then you probably recall the planets that used to be all over space. Of course if you had travelled outside the bounds of what we consider to be the singleplayer game map then you certainly would have found some of our old planets, but for a while now they have been decidedly absent from the core game systems. That’s because we have been cooking up a plan to put nicer looking planets in and honestly we just didn’t bother with placeholder planets while proper planets were being built.

Those planets are built now.

The system is possibly Jan’s masterpiece, so in the end this patch really became his patch. I’ve mostly spent all this time getting his code working inside our framework and fixing bugs while he mutters curse words about normal maps for hours in his own world of debugging hell.

The result looks like this:

best

That’s almost entirely done on the GPU. Here’s some of the highlights:

  • They are 3d and they rotate in real time with emission maps and fancy glowing bits on the dark side. Light direction and color is representative of the nearest star. We also did a bunch of camera improvements across the board so planets, asteroids, and foreground objects all coexist in 3d space in a more visually pleasing way.
  • Physically accurate atmospheres using precomputed luminosity thresholds and Rayleigh + Mie scattering – In other words we use the GPU to generate a 2d graph of how light of different wavelengths would scatter through air of different thickness. That lets us calculate the color value of every pixel as if the light had come from space and bounced off the surface and passed through a real atmosphere before getting to you. The end result is that we don’t need to draw a perfect looking atmosphere for different planet types and instead we can let an algorithm pick the properties of the atmosphere and the GPU will draw it accurately.
  • Unlimited combinations – They are procedural and parameter based, which means we no longer draw an entire planet and then render it in 2d, instead we give a series of parameters about temperature, color, height thresholds, etc. to the shader and render the result with a simple sphere. It means this system can make an unlimited number of unique looking planets to fill our galaxy without requiring us to upload an unlimited number of massive art assets or spend forever drawing islands and mountain ranges.
  • Power of creation – Similar to our other procedural generation algorithms, we wanted a system that would generate an infinite number of unique combinations to fill the galaxy with, however we also wanted the ability to hand craft a planet to our own specification. The result is a sort of hybrid procedural system where if we want we can specify every texture and every parameter used by the algorithm to give us complete control over specific planets. We will be using this in singleplayer to hand-craft some planets relevant to story elements and gameplay. It’s likely that any future mod API we make would allow the mod maker to choose to place either random planets or specific ones with their own code.
  • Efficient – The system takes full advantage of our backdrop extensions system to load, unload, and render everything in an instance. It is pre-generated in a background thread so there will be no load screen when approaching a planet you’ve never seen before and it’s managed so no matter how complex and awesome we make any individual planet it can never take more memory than the cost of the planet you are looking at right now.

 

red

Conclusion

I graduated from a public highschool in the United States so I fully believe every good article needs to end with a conclusion paragraph, and maybe a crayon drawing. So in conclusion, we now have an entire universe full of infinite eye candy. After the patch hits I encourage you all to open a singleplayer game with debug mode on (hold shift when starting the game) and fly around checking out all the procedural planets that litter the infinite galaxy of Zero Falls. Also expect that we will improve this algorithm over time, because the system’s power and capability is much greater than our current content for it. As we add new texture maps, parameter sets, and generation techniques the universe will slowly evolve more and more diversity of planet types.

 

Next time on blogging about patch 0.3.2.00

Next time I’ll be talking about the other big system overhaul that went into this patch: GPU particles.