Documentation/Tutorials/Making sky (sky box, sky dome and other methods)
From NeoAxis 3D Engine Wiki
|Language:||English • Russian||Status:||Approved|
In this tutorial, you will learn how to create the sky for your game environment.
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.
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.
The sky is created and you can start customizing it. Find SkyBox in the Objects window.
In the Properties window, you can adjust brightness, color, and other properties. Learn more about the object's parameters.
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.
Select the created object in the Objects window to configure it.
In the Properties window, you can set object's parameters. Learn more about object's parameters.
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.
Let's name the folder, for example NewSky. Click on it with the right mouse button and select the menu item New -> Entity type.
Now specify the name of a new type: for example NewSky. Select the class of the object being created: CameraAttachedObject.
Let's go into edit mode by double-clicking on the NewSky.type file .
First of all, add an attached object - the base of our sky. Press "..." in the Items field.
Add the mesh of the sky in the list of attached objects. Press the Add button and choose MeshItem.
Now choose the mesh file by clicking "..." in the MeshName field.
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.
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.
Save our object type by clicking the floppy disk icon in the toolbar.
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.
Now we have got the real sky with alive clouds.
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.
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.
Check to see how this material is arranged. To do this, go into the edit mode by pdouble clikcing the material file.
Among the parameters of the material, we are mainly interested in the Diffuse tab.
As we see, the material have two textures assigned. The first texture — Sky.dds is a panoramic image of the sky.
The second texture — Clouds.dds is an image of clouds.
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.