Sky Domes by (20 September 1999) |
Return to The Archives |
Introduction
|
Lately it seems that eye candy is becoming more important than game substance.
One of the reasons I hear that EverQuest is so much better than Ultima Online is
because the graphics are so much better. Personally, I am an avid fan of both
games. I have spent many hours looking around EverQuest trying to find these gorgeous graphics that everyone talks about. All I have seen are poorly aligned textures and level building that would get most Quake map makers laughed off a review board. After all is said and done, about the only thing that I have seen in EverQuest’s graphics is the nice sky dome. One of the nice things about sky domes is that with a little work, impressive results can be obtained. |
Elements of the Sky Dome Not Documented
|
To reduce the size of the source code in this tutorial, it is assumed that you
have access to some existing classes that provide basic functions.
In my world, the normal vector (0, 0, 1) points up. Elements such as texture management are not covered. |
The Source Files
|
Contained within this document is very little information about the actual
implementation of sky domes since the concepts are simple and fully documented
in the source code. Source code comments, what an earth shattering idea.
Contained within the source zip file, article_skydomes.zip, you will find the following
files;
Most of the code is well documented and will provide more information about how specific things are done. In this document, there will just be an overview about each element of the sky dome. IN NO WAY is this code intended to be able to be included in your project and compiled without modification. |
The Sky Dome
|
A sky dome is a top part of a sphere with the player usually located inside the dome
seeing the inside wall of the dome. Against the dome is drawn the environment. The following
image is a picture of a sky dome drawn as lines viewed from the outside. As you can see, the sky dome is broken into a series of triangles that reasonably approximate the shape of the sphere. When the sky dome is created, all that needs to be stored is the vertices. If all vertices are stored in a single array starting with the top of the dome and working down through the rings, the dome can easily be rendered using a triangle fan and a series of triangle strips. |
Texture Mapping a Cloud Texture
|
Clouds are drawn onto the dome by blending a luminosity texture with the
required texture color. A simple method of generating the texture coordinates
is to use some function of the x and y coordinates of the sky dome to generate
the s and t coordinates for the texture. To get a clouds texture to map over
the sky dome without any repeating, x and y should be divided by the width of
the sky dome base. Note: As the size of the dome is increased and it becomes more of a hemisphere, the texture mapping at the edges breaks down. One solution to this problem could be using some form of exponential curve to increase the textures ds and dt in triangles close to the edge of the dome. |
The Sun and the Moon
|
Paul Schlyter of Stockholm Sweden has published on a web site some great
information on how to roughly compute the proper position of celestial bodies
from the orbital information. Even though the equations he uses are
significantly simplified, they work far beyond the requirements for most games.
(EverQuest players need to take a look at the sun and moon in EverQuest and
figure out what is physically impossible about how there sun and moon rises and
sets.) Once the current game time is computed for the frame being rendered, these equations can be used to compute the position and size of all bodies. Of special importance is the sun, whose position is used to compute color information for the day and night. |
Day, Night, Sunset, and Sunrise Colors
|
As currently coded, the sky dome only includes a basic system of computing the
colors the clouds and bodies in the dome. It is based on a user-supplied color
for day and night. The sun is always in one of four states, day, night, sunset,
or sunrise. If the sun is in the day or night state, either the day or night
color will be used directly. If the sun is in sunrise or sunset, a color will
be interpolated based on how far into the transition state the sun might be in. One improvement that needs to be made to the code is the addition of sunrise and sunset colors, such as the red hues we see during a sunset. |
Rendering the Sky Dome
|
Rendering the dome is done in a series of steps:
Cloud layers are blended onto the frame buffer. In the case of sky bodies such as the sun, they are not blended, but required an alpha component so the texture does not overdraw elements of the dome that are not part of the actual sun. The moon has to be rendered in 2 passes. First, from the moon texture, which also has an alpha component, a mask is generated that has alpha values of 1.0 for texels inside the moon and alpha values of 0.0 for texels outside the moon. This mask is rendered onto the dome without blending using the current sky color. This is done to remove any stars that might appear behind the moon. Next, the actual moon texture is blended onto the sky dome. The reason it is blended is because during the day, the moon will show a bit of blue or red hue of the sky. Although not a real sky body, the code supports drawing of flares around the sun. These are done by creating duplicate sky body like the sun, but using a flare texture instead of the sun texture. Flares are blended onto the sky dome. |
Links
|
How to Compute Planetary Positions: http://hotel04.ausys.se/pausch/comp/ppcomp.html Solar Systems Data: http://seds.lpl.arizona.edu/nineplanets/nineplanets/data.html |
|