tAAt 2019 new year demo breakdown writeup

This is a bit more zen:

I wrote a sphere mesh generator a long time ago, and even back then I had this idea of making a "planet" generator. Even later on I made (well, ported) a procedural tree mesh generator. When pondering on what to do this year, I figured it's time to go down to it and make a planet. I had an early start but life interrupted the progress and most of the work was done in early December.

To start off, I made the sphere mesh and displaced the vertices (in their normal direction) by a bitmap.

Adding a water layer and atmosphere already made it look a lot more like a planet.

That's where things left for a few months, but I saw that the end of the year was approacing and picked it up again. Adding more sane heighmap and vertex colors, as well as adding protoype of the scroller ring.

I wanted to place items on the surface, so I worked out the math to rotate and translate things so they are sitting on the surface. The blue "diamond" meshes are there to test this (I think there are, like, several thousands of them there).

Now that I could place items I plugged in the tree generator and generated some random trees and placed them on random (non-water) points on the sphere.

Next up would be to get the scroller working. Up to this point everything was OpenGL 1.1 stuff, and I considered making the scroller that way too, but it's way easier with shaders, so I went through the trouble of converting everything to use shaders. After this making the scroller scroll was trivial.

And since there's shaders, I could start, well, shading.

Fun fact about the atmoshere: when the normals were flipped, it generated a different kind of effect - not bad, but not what I was looking for. Later on I saw some video made from the ISS and the atmosphere actually looks more like that flipped-normal one. Oops.

In any case, things started looking better right away. I added a cloud layer which would have been really tricky without shaders: there's three layers of prerendered cloud fractals which rotate and translate on top of each other, and then a nice min/max value is picked to represent the visible clouds. The result is complex enough that it's rather difficult to see how it works. In the demo itself the clouds also move so slowly that the clouds just keep forming and disappearing without any apparent pattern.

There's an ugly seam where the UV wraps, though, and I couldn't figure out what's causing it. I simply added a fade in/out to the seam to hide the bug instead of actually trying to fix it, though.

What, as usual, really made things pop was the addition of shadow maps. The screenshot here looks really "sharpened" because of surface acne; the final version has that toned down. On one hand the "sharpened" look is pretty neat, but it doesn't work in motion. I guess I could have added a sharpen filter pass.

While developing the demo I kept making the scroller slower and slower, to make it feel it had more mass. In the end the total runtime was around 15 minutes, but I had only made music for 10. I "solved" this by simply playing the music at half speed =)

At this point the demo was largely done. I figured a OpenVR version would be neat and easy to do.

Getting started with OpenVR is actually really easy, but it revealed a bunch of bugs in rendering that didn't really matter in 2d. My atmosphere calculations, for instance, completely blew up when the camera look-at wasn't pointing at the center of the planet. Oops.

In the end I did not figure out how the math for the atmosphere was supposed to work, so I turned the atmosphere into a 2d impostor. Good enough(tm).

Another little thing with the free camera was the fact that the scroller's starting point, on the other side of the planet, was rather ugly. I had to spend some time adding an effect back there to hide the seam.

The primary thing that blew up with OpenVR was scale. When I had it up and running I wondered why moving my head sideways didn't seem to have any effect, but when I looked at the scale I realized I was looking at a 200 meter wide object from 20 meters away, so moving my head 2 centimeters didn't have much of a parallax effect. I shrunk the planet to the size of a large beach ball and it works much better.

The VR version is pretty neat; If you have a chance, do try it out. It't fun to get really close to the planet.

The final version also has a few little details I haven't mentioned yet such as water level rising and falling, causing the coastlines to slowly change, clouds getting an orange tint in evenings and mornings, and last but not least the "hidden" tAAt logo on top of a mountain, glowing red in the evenings and mornings.

And there we go. Let's seriosly hope this year is better than the previous one.

Comments, questions, etc. appreciated.