Post news Report RSS Infinite Twilisphere

Extending the Twilisphere to the edge of the world!

Posted by on

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.


An old screenshot showing off the obvious problem of a finite sized twilisphere.

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:

distance = dot(P - O, N) / dot(D, N)

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 flat twilisphere at the horizon as far as the eye can see, and farther...


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).


Some screenshots of the infinitely large twilisphere as seen from an airship.

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!

- David

Post comment Comments
awesomepossum
awesomepossum - - 997 comments

Looks excellent, great job on the infinite clouds. Still love the nifty sun/shadow effects in the second to last screen.

Reply Good karma Bad karma+1 vote
Hamtaro
Hamtaro - - 95 comments

Getting nicer and nicer

Reply Good karma Bad karma+1 vote
Mularac
Mularac - - 2,910 comments

indeed... looking forward to this guys
oh, and can you give an estimated system requirements for the game?

Reply Good karma Bad karma+1 vote
terra0nova Author
terra0nova - - 178 comments

Theoretically, the game should run on a GeForce 6800 or comparable card and above. However, I haven't tested it on a 6800, and I can only imagine that it would be pretty slow (except in ultra-low quality mode). You should have a Geforce 7800 or equivalent card to really run the game, and I recommend a Geforce 9800 or equivalent for better quality settings. Some AMD cards don't work with the AE engine right now, but that will be fixed before the final release. As for CPU requirements, that is not known right now, as none of the current code requires much CPU computation. Once I add more of the CPU-based code (like the AI), there will be a CPU requirement, but it probably wont be very high compared to the GPU requirement. While the GPU requirement is high, remember, this game isn't coming out until 2010/2011... by then, some people will have GeForce 380's and above :P .

Reply Good karma+1 vote
Mularac
Mularac - - 2,910 comments

not if you have a laptop :P
hopefully for then I'll have my own desktop computer, but still...

Reply Good karma Bad karma+1 vote
terra0nova Author
terra0nova - - 178 comments

I've tested the game on a geforce 9200M laptop card (which is a fairly low powered card), and it runs decently at low quality settings - so you might have no problem playing Aero Empire even on a laptop (although you'll have to lower the quality settings).

Reply Good karma+1 vote
SweatbackSTEEN
SweatbackSTEEN - - 118 comments

yes?

Reply Good karma Bad karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: