Game Career Guide is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Get the latest Education e-news
  • Excerpt: Unity in Action

    - Joseph Hocking
  •  [Joseph Hocking explains how to create convincing skyboxes using Unity in this excerpt from his newly released book Unity in Action. Print and eBook versions of the complete volume are available here.]

    In my book, Unity in Action, I mostly cover how to program games. Still, it is important to understand how to work on and improve the visuals. Visuals are important because you don't want your projects to end up with just blank boxes sliding around.

    It's fairly easy to create walls in a game--you just use the Tiling property to place images of stone and brick. But things get a little more complex with creating a sky visual, one of the most common visuals you'll need to create in a game.

    If you want a realistic look for the sky, the most common approach is to use a special kind of texturing using pictures of the sky. In this article, I'll explain how to do this using a skybox, first by using provided sample material and second, by creating from scratch.

    What is a Skybox?

    By default, the camera's background color is dark blue. Ordinarily that color fills in any empty area of the view (e.g., above the walls of this scene) but it is possible to render pictures of the sky as background. This is where the concept of a "skybox" comes in:

    DEFINITION: A skybox is a cube surrounding the camera with pictures of the sky on each side. No matter what direction the camera is facing, it is looking at a picture of the sky.

    Properly implementing a skybox can be tricky; figure 1 shows a diagram of how a skybox works. There are a number of rendering tricks needed so that the skybox will appear as a distant background. Fortunately Unity already takes care of all that for you.

    Figure 1 - Diagram of a Skybox

    New scenes actually come with a very simple skybox already assigned. This is why the sky has a gradient from light to dark blue, rather than simply being a flat dark blue. If you open the lighting window (the menu Window > Lighting) then the very first setting is Skybox and the slot for that setting says "default". This setting is in the Environment Lighting panel; this window has a number of settings panels related to the advanced lighting system in Unity, but for now we only care about the first setting.

    Just like the brick textures earlier, skybox images can be obtained from a variety of websites. Search for "skybox textures"; for example, I obtained several great skyboxes from including their TropicalSunnyDay set. Once this skybox is applied to the scene, you should see something like figure 2.

    Figure 2 - Scene with background pictures of the sky

    As with other textures, skybox images are first assigned to a material, and that gets used in the scene. Let's examine how to create a new skybox material.


comments powered by Disqus