The skybox

While space may be infinite, your computer isn't so there has to be a boundary somewhere. This boundary is called the skybox.

Imagine that our spaceship is flying through space! Space is big. While we may put some planets and asteroids in our universe to give the space ship something to interact with, we certainly won't model every star. Here is what our universe looks like:

The skybox

This is pretty empty, right? You probably already noticed this in our game, SpaceRacer3D. Of course, we could add some more objects of our own—more asteroids, add a bunch of stars—and in a real game, we would. But, there is always a limit to how many objects you can add to the game before you start having performance issues.

For the really distant objects, such as distant stars, we fake it by using 2D textures. For example, our game could use a texture of stars to imitate the stars and nebula in space, as shown in the following image:

The skybox

Now, as a cube has six sides, what we really want is six textures. A typical skybox looks similar to the following image:

The skybox

It doesn't take too much imagination to see how this texture can be wrapped around the cube and cover all size sides. This creates an image that covers all of the space encapsulated by the skybox and gives the illusion of being surrounded by stars and nebula, as shown in the following image:

The skybox

The following illustration shows the skybox in relation to the texture that will be applied to it from another perspective:

The skybox

The cube containing the ship and asteroid represents the game world. The ship and asteroid are real objects in that world. The image on the left is a texture that contains the stars.

Now, imagine the star texture being wrapped around the cube, and there is your whole universe composed of the stars, the ship, and the asteroid. The star texture wrapped around the cube is the skybox.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.31.222