Documentation/Tutorials/Making sky (sky box, sky dome and other methods)

From NeoAxis 3D Engine Wiki

Jump to: navigation, search
Go to higher level



In this tutorial, you will learn how to create the sky for your game environment.

Sky created with the SkyBox object

When configuring the map, there are 3 ways to create the sky:

  • Standard Sky Box type, representing a cube in which the gameworld is placed. The Texture of the sky is applied on the walls of the cube(cube texture).
  • Standard Sky Dome type, representing a hemisphere.
  • With the help of a special class CameraAttachedObject. This method is more complicated than the previous ones, but gives maximum flexibility. The geometry of the sky is a 3D model, which the developer creates in advance.

In this tutorial, all three ways will be examined in details. On the map, add the Water Plane type to make the test world less empty.

Map with water plane

Sky Box Creation

The first way to create the sky is to use the SkyBox object. The object represents a cube in which the gameworld is placed. The Texture of the sky is applied on the walls of the cube(cube texture).

Choose SkyBox in the lists of types Base -> Types. When SkyBox is selected, click on the work area of the editor.

Creation of a SkyBox on a map

The sky is created and you can start customizing it. Find SkyBox in the Objects window.

Selection SkyBox in a list of objects

In the Properties window, you can adjust brightness, color, and other properties. Learn more about the object's parameters.

CreatingSky 004.jpg

Sky Dome Creation

The second way to create a sky is to use the SkyDome object. Unlike the Sky Box, the Sky Dome is an hemisphere. It offer more features than the Sky Box:

  • possibility to have an animated sky
  • use up to four textures in mixing mode,
  • A separate texture is used to configure a smooth mixing of the horizon.

In the list of types Base -> Types select type SkyDome and click on the working area of the editor.

Creation of SkyDome on a map

Select the created object in the Objects window to configure it.

Select SkyDome in the list of objects

In the Properties window, you can set object's parameters. Learn more about object's parameters.

CreatingSky 007.jpg

Creation of the Sky with CameraAttachedObject

The third way to create the sky is to create your own type based on the CameraAttachedObject class. This class allows you to customize the 3D model(s) that will be attached to the camera position (i.e. will move along with it). This method of creating sky is more complex than the previous ones, but it's also the most flexible one.

An example of such object is presented in the SDK folder Data\Types\Sky\BlueDaySky.

To create the sky, the first thing we need to do is to create the object type in the Resource Editor.

You need to create a new type based on the CameraAttachedObject class in the resource editor. Let's by creating a directory for our object type. Click the right mouse button on the folder Types\Sky, choose New -> Folder.

CreatingSky 008.jpg

Let's name the folder, for example NewSky. Click on it with the right mouse button and select the menu item New -> Entity type.

CreatingSky 009.jpg

Now specify the name of a new type: for example NewSky. Select the class of the object being created: CameraAttachedObject.

CreatingSky 010.jpg

Let's go into edit mode by double-clicking on the NewSky.type file .

CreatingSky 011.jpg

First of all, add an attached object - the base of our sky. Press "..." in the Items field.

CreatingSky 012.jpg

Add the mesh of the sky in the list of attached objects. Press the Add button and choose MeshItem.

CreatingSky 013.jpg

Now choose the mesh file by clicking "..." in the MeshName field.

CreatingSky 014.jpg

As an example, you can select the mesh which is used in the SDK type BlueDaySky, which has been created the same way. The Mesh is located in the Types\Sky\BlueDaySky folder.

CreatingSky 015.jpg

Let's specify three parameters for our MeshItem. First of all, for the AllowFrustumGlobalClipPlanes parameter, choose False, because there is no need to apply the clipping plane to the sky. Secondly, for RenderQueueGroup, choose SkiesEarly to make the engine aware that the sky needs to be drawn before the other objects. Third, for ThisIsSkyGeometry choose True, so the engine will know that this is the sky.

CreatingSky 016.jpg

Save our object type by clicking the floppy disk icon in the toolbar.

Saving of the creating sky

Run the map editor. Add the sky on the map like we did in the previous parts of the lesson. Select NewSky in the list Types -> Sky and click on the working area of the editor.

Adding a new sky on the map

Now we have got the real sky with alive clouds.

New sky on the map

BlueDaySky Configuring

Now let's go back. Remember that, as the object attached to the camera, we have chosen the ready BlueDaySky.mesh mesh. Open it in the editor (the directory Data\Types\Sky\BlueDaySky) and take a closer look.

BlueDaySky.mesh, using in the type BlueDaySky.type

As we see, the mesh is the internal part of the hemisphere with textures. Consider the material that is assigned to the mesh. Let's open the BlueDaySky.highMaterial in the same folder.

BlueDaySky.highMaterial, using in BlueDaySky.mesh

Check to see how this material is arranged. To do this, go into the edit mode by pdouble clikcing the material file.

CreatingSky 022.jpg

Among the parameters of the material, we are mainly interested in the Diffuse tab.

CreatingSky 023.jpg

As we see, the material have two textures assigned. The first texture — is a panoramic image of the sky.

CreatingSky 024.jpg

The second texture — is an image of clouds.

CreatingSky 025.jpg

Besides, if you open the tub Diffuse2Map, you can see that, in addition to the texture file, one parameter Transform is specified. Opened it, pay attention to the parameter Animation. The animation is set with the parameter Scroll (scrolling). It is used to animate the clouds.

CreatingSky 026.jpg