jump to navigation

SkyPlane issues September 4, 2006

Posted by samwyse in Interactive Fiction.

I can hear most of you asking already, “What’s a skyplane?” It is one of the three common ways to draw the sky in a computer image. The problem is that the sky is a hemisphere, which is round, while computer images are rectangular, and flat. Placing a flat rectangular picture on a round sphere requires streching the picture, and there are several ways to do that.

The first method is a skydome. You take a hemisphere and slice it vertically into wedges and horizontally into disks, winding up with something like this:
[Sphere wireframe image]
For the most part, this works well, unless you look straight up. Then, all of the little squares want to turn into triangles, and you have a big traffic jam at the north pole.

The second method is the skybox. Here you try to sidestep the problem by using a cube instead of a sphere as the sky, so your flat pictures don’t have to be distorted at all. Unfortunately, you have to pre-distort the pictures yourself, or else the edges and corners of the box become obvious, like this:

That leaves us with the skyplane. Imagine your picture is on a piece of cloth, and you drap it over a sphere. Ideally, you’ll wind up with something like this (only turned over):
This shape is an elliptical paraboloid. It’s hard to tell in the picture, but the pointy end is actually rather blunt, so flat pictures fit on it rather well.

The problem is, if you search the web for information about skyplanes, you won’t find anyone who seems to know what the shape is. This means that the code that they use to draw the thing has all sorts of wierdness. For example, in one case you had to specify parameters named “PlanetRadius” and “AtmosphereRadius”. Unfortunately, there was no explaination of how to choose the proper values, nor warnings about what would blow up if choose unwisely.

What no one seems to understand is that all parabolas are geometrically similar. In practical terms, this means the we only need to calculate one paraboloid, and then use standard CGI transformation matrices to scale it to our needs. So, that’s how I’ve written my skyplane code. The math is very simple and easy to understand, and after the mesh is generated, you use scaling and translations to put it where you want it to be.



1. none - November 5, 2008

can you show us your algorithm?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: