Many of you may have noticed that the twilisphere (the massive cloud covering Aero Empire's world) is rather small, and does not cover the horizon like it should if it extended all the way around the planet. This is because I had not done any work making the twilisphere, and had just stuck a box cloud in there the size of the scene. However, the size of the scenes were only 6km by 6km, which at the heights many of the screenshots took place made the box look very small.
One obvious solution is to just make the twilisphere object bigger - scale the size of the box up. However, because of the way rasterization on graphics hardware works (by transforming points using a projection matrix), you must set a near and far plane for rendering the scene, where everything before the near plane and everything after the far plane is cut off. While you can increase the size of the near and far plane arbitrarily (in fact, you can even increase the far plane to infinity using projection matrix tricks), this lowers the rendering quality because of floating point precision errors, the depth map which has lower resolution the farther apart the near and far planes are (causing z-buffering errors), and finally the split shadow mapping technique which can get better shadow resolution using less shadow splits if the near and far plane are closer together. In practice, the farther out you can push the near plane, and the closer in you can bring the far plane, the better - you just have to make sure you aren't clipping anything in the scene that would be noticeable. Unfortunately, if you scale the twilisphere to a size where it fills the horizon at any in-game reachable height, you either have to push the far plane much farther out which lowers the rendering quality, or you have to accept the fact that the twilisphere will be clipped, in which case, it doesn't fill the horizon anyways.
So, the solution to this problem was to use raytracing instead of rasterization to render the twilisphere. One nice advantage of raytracing over rasterization is that it can render implicit shapes - all raytracing needs to render a shape is to have an intersection function that determines where a ray intersects that shape. So, you can render a true sphere with raytracing, by having a ray-sphere intersection function. No matter how close you get to a raytraced sphere, it will still look spherical, whereas a rasterized sphere must be triangulated, which means if you get close enough, you can see the individual triangles. You can also render an infinitely large plane with raytracing - even though it is infinitely large, as long as you can compute the intersection between a ray and a plane, you can raytrace the plane. The ray-plane intersection function happens to be very simple:
Where distance is the distance between the ray origin and the plane, P is a point on the plane, O is the ray origin, D is the ray direction and N is the normal of the plane. While in general raytracing is too slow to do in real time - for a single simple shape like this, with the intersection computation running in a pixel shader, it happens to be very fast. Using the ray intersection point and some manipulation of the output data structure I created for rendering clouds, I can render an infinitely large and infinitely deep flat cloud plane.
Sinking into an infinitely deep twilisphere: no bottom in sight, no bottom at all!
A few questions people might have about the new twilisphere is whether being infinitely large and infinitely deep is accurate - I mean, the planet isn't infinitely sized. However, the infinite plane is only what is being rendered, meaning that the actual size of the planet and it's curvature is taken into account in terms of where you are and what mountains you see on the planet. So, except for the fact that the twilisphere shows no curvature of the planet that it should due to the curvature of the planet, it is a fine representation for what you would actually see. As for the curvature of the planet, while at the higher altitudes you would be able to see the curvature, and that would be pretty cool, it is not a big deal, and unfortunately the atmospheric scattering algorithm does not take altitude into account (nor do the clouds have any atmospheric scattering on them either). Swapping out the flat twilisphere with a curved one would just require swapping the flat plane intersect function with a very large sphere intersect function (which is also very cheap to compute and easy to add), but unless the atmospheric scattering problems are fixed, it would not really fix the problem of viewing the scene at very high altitudes.
As for infinitely deep - don't worry about that. I assure you, your ship will be destroyed long before it could get deep enough to tell that the twilisphere was infinitely deep. There will not be any ships capable of venturing below the twilisphere in the initial release (although maybe in expansions). To fix this problem, the intersect function just has to be changed to also compute the exit depth of the cloud (which increases the complexity a little, but is not a big deal).
The only problem with the twilisphere now is the fact that the twilisphere is a plane, meaning it is perfectly flat. However, the solution to this is simple: Just place stratus clouds right on top of the twilisphere within the scene - that way it gets the details and bumpiness it should get within the scene, and outside the scene the twilisphere still exists, it's just infinitely flat (but at that distance, it would look flat anyways). So, that's the twilisphere taken care of. The new mountains still need textures (our texture artist is working on mountain textures), but other than that we have the basic landscape and clouds set up for the upcoming demo.
Stay tuned for more updates - including the initial design of the HUD and controls for the gyros!