Game Creation with XNA/3D Development/Skybox

< Game Creation with XNA < 3D Development

Skybox

Skyboxes give a game a surrounding and grounding. Be it a race car, ego-shooter or space simulation, the skybox makes the game feel more realistic. At its most primitive version it is simply 6 images projected onto the sides of an imaginary cube way out at infinity. Here we show you how to easily create simple skyboxes. But skyboxes can be more complex also. They can be dome shaped, they can simulate dusks and dawns with rising sun. Also examples for how to create those are given.

Creating a simple Skybox

First you will need to create the six images for each cube face. There are several ways to accomplish this. However it depends on what you want in your scene. So you could could take the some digital pictures and generate the skybox from them. Another possibility would be use a skybox someone else created (public domain). Naturally, you have the most freedom if you create everything from scratch. And that’s what we are going to do. In the following our tool of choice will be Terragen 2 (non-commercial version).

Creating Skybox Images with Terragen 2

My focus is on bringing you quick results rather than in depth information. If you have the desire to dig in deeper, please check out the tutorials i have based my guide on.

Once you have started Terragen, you see the default scene, consisting of a flat planet with an atmosphere. First thing you want to do is to change this flat space into a more interesting landscape.

Adding Terrain

You use heightfields and procedurals to generate Terrain in Terragen 2.

Using Heightfields

Wait for the Renderer to complete and enjoy your first rendered view. Now use the navigation controls to get to position very high above ground so you can see the horizon. You will notice that there is still a lot of flat surface. This is becasue of the limitations of Heightfields. We may want to change this now using Procedurals.


Using Procedurals

Texturing using Shaders

Now we will add better colors and textures using Shaders.

Modifying the mountain ground color
Adding a grass like texture

You may want to spend some time adjusting all parameters mentioned above to shape everything the way you like it to be. Render to see the effects of your adjustments.

Controlling the appearance of the grass layer

As you see it Terragen2 is a mighty tool, but this is just the beginning. You could go on and add snowy mountains, fast valleys and water and then integrate atmospherics and lightning. We leave it for now and start building our skybox.

Camera Setup

Now you have to decide which point of view you want to present in your projects skybox. Go on an find a good spot using the navigation controls.

Switch to the Cameras layout Here you will see a list of your new cameras. And the default Render Camera. We will use these six cameras to render all views we need for the skybox. But first we have to configure them:

Edit the other cameras as shown in the table below:

Camera01 Camera02 Camera03 Camera04 Camera05 Camera06
Name North East South West Up Down
Position a/b/c a/b/c a/b/c a/b/c a/b/c a/b/c
Rotation 0/0/0 0/90/0 0/180/0 0/270/0 90/0/0 270/0/0
Perspective Selected Selected Selected Selected Selected Selected
Horizontal FOV Selected Selected Selected Selected Selected Selected
Value 90 90 90 90 90 90

Note: a/b/c is a placeholder for your position values. Once you have found a camera positon you want to use for the skybox you can just copy the same values to all six cameras.

Go back to to the Renderers layout

Render/Quality Settings

There are two pre-configured Renderers in Terragen 2. The Full Render is intended to generate high-quality output. Therefore you will just use it when you want to test how your project really will look like, or you want to render and export. It depends on your settings but expect this renderer to take some time. The Quick Render is intended to give you a quick impression and therefore the render time is short. Of course you can configure both of them matching your needs, or create additional Renderers.

Now we are going to configure the Full Render and then create all images for the skybox.

Go to the Renderers layout

Note on using GI in your scene:
You might want to turn off GI (Global Illumination) by setting GI relative detail, GI sample quality and GI blur radius to zero.
This is because GI can lead to visible edges in your skybox. You may have to adjust your lightning configuration to lighten up you scene.

Once you have rendered all cameras, you might want to align the images in your favorite image editing program, and check how they all fit together.

XNA integration

Creating a skybox cube map

One way to get your skybox into your XNA project is to generate a cube map file which you can easily load later on. A quick and easy way to archive this is by using a tool called CubeMapGen from ATI.

In CupeMapGen:

Based on the alignment of the skybox images created earlier, the axis mapping is as follows:

East West Up Down North South
X+ X- Y+ Y- Z+ Z-

Save the cube map as DDS file by clicking Save CubeMap (.dds) button when done.

Integrating a skybox cube map in XNA

Tutorial

Skydome

Same concept as a skybox but instead of a cube, a sphere is used. Can be used to simulate atmospherics and sun movement (dawn, dusk).
See Tutorials on how to create these.

Links

Terragen

http://www.planetside.co.uk/wiki/index.php/Terragen_2_Tutorials#360.C2.BA_Panoramas_.2F_SkyBoxes
http://www.planetside.co.uk/wiki/index.php/Main_Page

Skybox

http://en.wikipedia.org/wiki/Skybox_(video_games)
http://wiki.delphigl.com/index.php/Skybox

Skybox Tutorials

http://wiki.delphigl.com/index.php/Skybox
http://www.stromcode.com/2008/03/30/building-an-xna-skybox-with-blender/
http://rbwhitaker.wikidot.com/skyboxes-1
http://wiki.delphigl.com/index.php/Tutorial_Skyboxen

Skyboxes

Ready and free to use skyboxes (public domain):
http://rbwhitaker.wikidot.com/texture-library

Skydome

http://wiki.delphigl.com/index.php/Skydome

Skydome Tutorials

http://www.xnamag.de/article.php?aid=40
http://www.flipcode.com/archives/Sky_Domes.shtml
http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Build_a_skybox

Other

http://en.wikipedia.org/wiki/Cube_mapping

References

http://www.planetside.co.uk/docs/tg2/first-scene.pdf
http://www.outpt.co.uk/how-to-create-a-terragen-2-skybox/

Authors

arie

This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.