Chapter IX. Sky.

Creating sky: box and perimeter methods, standard sky names, and making custom skies with Terragen.

9.1

Simple Sky — The Box Method

In this article we look at a very simple method for creating a sky. It does not require a lot of time and much effort, but it has some disadvantages, which we will try to minimize by using some tricks. We hope that you have already learned how to create "closed" maps, without the sky, representing one or more interconnected rooms.

What is heaven?

The sky in Half-Life (CS) is a simulation of open space, which is implemented as follows:
  1. SKY brushes built around the map
  2. A picture of the sky recorded in the map properties
SKY brushes - these are ordinary brushes (although very large in size), painted on ALL SIDES with a special texture called SKY. SKY brushes are placed around the card, forming a kind of cap that separates the card from the external "vacuum".
Visually, the sky in Half-Life can be represented as frying pans with transparent lid, where the frying pan is your level, and the transparent lid is the sky. The lid should fit tightly to the edges of the frying pan, there should be no cracks or holes leading to the "outside world". This is a mandatory and very important condition when creating the sky. The sky must completely separate the map from the outside world, otherwise a compilation error will occur (the notorious LEAK error).
Why is the lid transparent? The fact is that the sky itself, i.e. SKY brushes are transparent for the game. In fact, the player sees a PICTURE, or more precisely 6 sky pictures, superimposed (projected) onto the sides of an imaginary cube. This cube is located outside the map (outside the frying pan with a transparent lid :). Imagine a large cube behind a map with pictures of the sky superimposed on its sides. The player looks through the transparent lid of the frying pan and sees these pictures. The pictures were created in a special program and adjusted to each other in such a way that the player gets the impression that he is seeing an ordinary "round" sky, and not pictures superimposed on a cube.
Only texture is used to create the sky SKY. There should be no other textures on the sky brushes except SKY. This is another mandatory condition.
In this article we will build a simple sky - one large box around the card. We will simply place our entire map in a huge room, painted on all sides with texture SKY.
Well then. Suppose we have such a small open map, very simple in design (see figure below).
Open card
As you can easily calculate, the map consists of only 5 brushes (1 brush for the ground and 4 brushes for the sides). Just in case, we report the dimensions of the map: the ground has dimensions of 512x384x64 units, and 4 sides are 48 units high.
Select texture SKY (it is in the standard and largest texture library halflife.wad) and build a large brush around the map so that the map is completely in it, and there is still some space left around the edges (preferably 16-32 units on each side).
The pictures below show the top and front views and the outlines of the SKY brush being created. In principle there is no need to leave so much empty space to the edges of the card. This is even harmful and will slow down compilation. It's better, of course, to build SKY-brushes close to the walls of the map, but for now let it be so - with a margin.
t8sky3 t8sky4 After we finish creating the SKY brush, by pressing "Enter", we need to turn it into a ROOM. We discussed this operation in detail in the article. Creating Hollow Objects with Hollow.
That is, we had one SKY brush, and after using the function Hollow, a room appeared consisting of 6 SKY brushes (floor, ceiling, walls). Creating a room of 6 SKY brushes is necessary for the sky to work. Now our map is inside a room consisting of 6 walls, completely painted with texture SKY.
How to apply Hollow: select the SKY brush and click [Ctrl-H], that is, we use the Hollow function - we add thickness to the walls of the brush. In the window that appears, you need to indicate the thickness of the walls of the room. You can leave the default value: 32.
Simple sky is ready! After this operation, the map should look something like this:
This is what a map with the sky looks like

Reducing harm from box sky (method No. 1)

Most likely, you will have some space between the walls of the room and the map (as in our picture). It is advisable to make the room exactly the size of the map, so that there is no space left either near the bottom or near the walls of the map. That is, you need the walls of the room to be in contact with the walls and bottom of the map. But on the contrary, there needs to be some space on top of the map so that players don't hit their heads against the sky and can jump freely. This advice will help reduce the work of compilers, which will not need to calculate the empty space around the map.

Reducing harm from box sky (method No. 2)

When you have created a tight-fitting room of SKY brushes around the map, you need to reduce the work of the compiler HLRAD, which calculates the lighting on the map. The fact is that the lighting on the map is projected precisely from SKY textures. Compiler HLRAD determines where SKY brushes are located and projects lighting from them onto all other objects that have any texture. That is, it will calculate both the bottom and the outer sides of the map, because they have textures and come into contact with SKY brushes, "seeing" the sky.
It should be noted that the operation of calculating lighting is the longest of all and also the most demanding of computer resources. Therefore, it is imperative to PAINT ALL OUTSIDE SIDES of the card SKY texture. But in this case, naturally, not to create the sky, but simply so that the compiler HLRAD I did not calculate the lighting for these surfaces. SKY texture is simply ignored by this compiler! It would be a sin not to take advantage of this wonderful property and not significantly speed up the map compilation process.
The pictures below show the unpainted and shaded outer sides of the card (this card also has a shaded bottom), which the player will never see in the game. These surfaces will not be calculated for lighting, thereby compiling time will be significantly reduced (the larger the map, the greater the savings, sometimes up to 50% of time is saved!). You can also paint over the roofs of houses and any other surfaces that the player will NEVER SEE in the game. By the way, thanks to this, the size of the card (in MB) is also reduced.
t24rspeeds28 When creating a box sky, all external walls and the bottom of the map must be painted over with the SKY texture
You can also paint over house roofs and other similar surfaces that are invisible to the player with the SKY texture.
Paint over surfaces invisible to the player with the SKY texture
That's all about optimizing the map for a simple sky box. If these simple two measures are not followed, then with a large map, the compilation time can become very long. Agree, there is a difference in how long you wait: 1.5 hours or 40 minutes.

Selecting a picture of the sky

As mentioned above, the sky itself is transparent, and the player sees 6 pictures of the sky projected onto an imaginary cube.
Pictures with images of the sky are in the directory "cstrike\gfx\env.."and have the format TGA 24-bit and sizes 256x256 pixels. It is also possible to use images in the formats PCX And BMP 8-bit, but they are only needed for playing on old, old video maps without a 3D accelerator. All modern video maps have an accelerator, so there is no need to use BMP and PCX formats.
Since the pictures are superimposed on the sides of the cube, there are 6 pictures of the sky in total. The names of the pictures have the following format:
skynameRT.tga - right picture (from English. right)
skynameFT.tga - front picture (from English. front)
skynameLF.tga - left picture (from English. left)
skynameBK.tga - back picture (from English. back)
skynameUP.tga - top picture (from English. up)
skynameDN.tga - bottom picture (from English. down)
Where skyname is any combination of letters and numbers indicating the name of the sky.
Each of these pictures is "drawn" in a special program (there are several of them) in a rather cunning way :) - if you put them next to each other, they form a closed space (a single landscape). It should be noted that the appearance of these pictures in the game does not depend in any way on the shape of the sky (SKY brushes). It's just that where the player sees SKY brushes, he sees the sky (pictures projected onto a distant imaginary cube).

Specify the name of the sky

So, choose your favorite sky picture and remember its name. Drop it 2 LAST LETTERS (RT, FT, LF, BK, UP, DN).
In the editor, open the window with general properties of the map "Map\Map properties..." And enter the name of the sky in the parameter environment map (see picture below). WITHOUT THE LAST TWO LETTERS!
Below we have written the name des - this is the sky from DE_DUST.
t8sky1 And this is what our map will look like in the game:
This is how the sky map from de_dust looks like in the game

Recommendations for choosing a sky picture

Try to match the sky to the architecture and color of the main map textures. For example, if the map is light and there are mountains on it, then you should choose a picture with mountains and a light sky. If the action on the map takes place at night, in the city, then the sky in the picture should be night, etc.
Now all that remains is to place the light source light_environment inside the card, i.e. under a hood of SKY brushes and start compilation.

Disadvantages of the sky-box:

[–] you can fall outside the map if you do not additionally use CLIP brushes that limit movement, or if the sky is not close to the map;
[–] the HLVIS compiler takes longer to optimize the visual part of the map due to the calculation of extra clipnode planes outside the map;
[–] compilation time increases due to miscalculation of lighting of external (invisible in the game) surfaces of objects;
[–] larger size of the finished map

Advantages of the sky-box:

[+] fast production
[+] You will never encounter the dreaded :) LEAK error
[+] Provided that two steps are followed to optimize the map with a sky-box, most of the shortcomings disappear
As you can see, there are several advantages and quite significant ones, however, if you do not optimize the map, then the 4 disadvantages will turn out to be much more significant. In principle, it can be argued that sky box - this is bad, but for simple and small maps it is quite acceptable. On large maps, we recommend creating a more complex, but also more correct sky. Creating the right sky will be discussed in the next article of the Tutorial.
sky_simple.zip [9Kb] - in the archive there is an example map in BSP and RMF formats.
9.2

The Correct Sky (Perimeter Method)

In this article we will look at how to create the correct and most competent sky for Half-Life (CS) maps. A complex (regular) sky has a number of advantages over a simple sky built in a box around a map. The main ones are lower compilation time and higher FPS on the card.
To create the right sky, the same SKY brushes, i.e. ordinary brushes painted on all sides with the texture of the sky SKY. Let's look at creating the right sky for a map whose shape is a little more complex than a simple rectangle (see image below).
Example of an open card
Let's start creating the sky from the sides. We will build SKY brushes around the perimeter of the map (see figure below).
Creating SKY brushes around the perimeter of the map
Done (see picture below). The height of SKY brushes is chosen arbitrarily. It can be 384, 512, or more units, but for our convenience it should be the same for all side SKY brushes. It is also advisable that players do not hit their heads against the sky :)
t8advsky3 Please note that the hole in the center of the card also needs to be closed with a SKY brush from the BOTTOM (see figure below), which exactly matches the hole in length and width. We remember that the sky must completely protect the map from the "external vacuum". Remember our conversations about the frying pan lid fitting tightly to the edges in the last article :) There should be no holes or cracks, otherwise an error will occur LEAK.
t8advsky4 The hole in the center was closed. Now you need to close the top of the card. We do this using two fairly large SKY brushes (see figure below).
t8advsky5 We could stop here, because... the sky itself is already complete, but let's also limit the player's movement so that he can't fall into the central hole. To do this, we will build in place of the hole CLIP brush, i.e. regular brush, painted on all sides with special paint. texture CLIP. Such brushes are invisible in the game, but the player cannot pass through them and, accordingly, cannot fall into the hole (see figure below).
CLIP brush is equal in size to the hole, it starts from the upper sides of the sides and continues all the way to the sky, but does not "enter" it.
In place of the central hole we build a CLIP brush
Now all that remains is to place the light source light_environment inside the card, i.e. under a hood of SKY brushes, and also indicate the name of the sky picture in the menu "Map\Map properties..." in the parameter environment map. We talked about how to correctly indicate the name of the sky in the previous article about a simple sky with a box.
And here is the result (see figure below). As you can see, the sky pictures are superimposed not on the manufactured SKY brushes, but on some large remote (imaginary) cube, which is the same for all maps.
This is what the map looks like in the game

Advantages of complex palate over simple palate

We conducted a simple experiment: instead of creating a regular sky on the same map, we created a simple one (in a box) and then compared log files that record the progress of the compilation, as well as detailed statistics of the BSP file (if we use the -chart parameter). Here are the results we got (see figure below).
t8advsky8 Let us briefly explain what these parameters mean.
Compile time - everything is clear here, compiling a map with the correct sky is twice as fast... impressive :)
Lighting miscalculation — on a map with a sky-box, all surfaces outside the map are additionally calculated, which leads to a significant increase in compilation time even on small maps.
Clipnodes — the number of planes limiting the player's movement. These should not be confused with placed CLIP brushes, they are not exactly the same thing, although CLIP brushes also add clipnodes to the map. By the number of clipnodes one can judge the work done by the HLVIS compiler. The fewer clipnodes, the less work HLVIS had to do.
Faces — number of surfaces. The fewer of them, the less work for the HLRAD compiler, which calculates lighting.
Patches — number of patches. When compiling a map, all visible surfaces of objects are divided into patches of a certain size. The default patch size is 64x64 units, but this can be changed with the -chop option. The fewer patches the better. If there are too many patches (more than 65535), the MAX_PATCHES error will occur. Therefore, it is necessary to monitor the number of patches and, if necessary, reduce them.
Lightdata — a parameter showing the total amount of information about the map's lighting.
Visdata — a parameter showing the total amount of visual information on the map.
As you can see, the time saved on building a simple sky, instead of a complex one, is spent during compilation. Hence the rule :) - for large maps, always build the correct sky, and for small ones you can get by with a box sky, but just don't forget to optimize the map, as written in the previous article.
sky_advanced.zip [29Kb] - in the archive there is an example map in BSP and RMF formats.
9.3

Standard Sky Image Names

Below is a complete list of sky image names for standard CS maps. The name must be entered in the "Map/Map properties" menu in the parameter environment map.
Names of standard map sky pictures
Name Map Image
backalley cs_747
cs_backalley
de_vegas backalley
badlands de_inferno badlands
blue as_oilrig blue
cx de_chateau
de_piranesi cx
city1 cs_assault city1
cliff cs_militia cliff
de_storm de_storm de_storm
des de_dust
de_dust2 des
desert de_nuke desert
doom1 de_aztec doom1
dusk de_cbble
de_prodigy dusk
green cs_italy green
grnplsnt cs_siege grnplsnt
hav cs_havana hav
morningdew cs_estate morningdew
office cs_office office
snow as_tundra snow
snowlake_ de_survivor snowlake_
tornsky de_torn tornsky
trainyard de_train trainyard
tsccity_ de_vertigo tsccity_
9.4

Creating Custom Sky Images with Terragen

From this article you will learn how to use the program Terragen You can create sky pictures to use on your map. When writing this article, materials from the site were partially used http://gamedesign.net/. Thanks to the author: Mithodiel.

PART ONE. About the sky in Counter-Strike

1.1 Environment Map (sky)
Environment Map is a graphic representation of a natural landscape. In relation to Counter-Strike, these are 6 pictures of the sky, which are generated in such a way that they display the entire space around the player.
By creating the sky around the map using SKY brushes, we indicate to the game engine where the player should see the sky images. Then 6 pictures are superimposed on the sides of an imaginary cube, located as if behind the card. Therefore, the pictures can be named according to the sides of the cube: upper, lower, left, right, front And back.
1.2 Where are the sky pictures stored?
Sky pictures for Counter-Strike maps are stored in the folder "cstrike\gfxenv..".
1.3 Size and format of sky pictures
The size of pictures is strictly limited and is 256x256 pixels. The main format is TGA (24-bit). Previously, when there were no 3D accelerators, the format was used PCX And BMP (8-bit), however, now there is no need for these formats.
1.4 Names of sky pictures
In order for the sky to be displayed correctly on the map, each sky picture must be named correctly. The names of the pictures are compiled according to the format: nameXX, where XX is one of 6 endings (see below).
  • NameUP — up (top picture)
    NameDN — down (bottom picture)
    NameLF — left (left picture)
    NameRT — right (right picture)
    NameFT — front (front picture)
    NameBK — back (back picture)
What comes before these letters does not matter, you can enter anything here. But the last two letters of each picture should be exactly like this. This was done so that the game engine knew which image to project onto which face of the cube.
And here's how the sky pictures are "joined" (mentally fold this scan into a cube and get the sky in CS):
Arrangement of sky pictures depending on the name of the picture
When you create a map and determine what sky will be on it, then in the menu "Map\Map properties..." into parameter environment map You enter only the name WITHOUT the last 2 letters! For example, for the map De_dust we would enter the name des, and for De_aztec - doom1.

PART TWO. Creating sky pictures using Terragen

Now let's move on to using the Terragen program to render images.
About Terragen
The program is paid, but it can be used for free with some restrictions. Or you can use a crack, of which there are plenty on the Internet :)
The main advantages of Terragen over other similar programs are: its small size, as well as fast image rendering (even on weak computers).
In Terragen you can create various natural phenomena such as fog, lightning, etc.
There are a large number of plugins for this program that expand its capabilities, for example, using plugins you can create a forest, waterfalls, houses, etc. against the background of a landscape.
In this article we will teach you how to create the simplest sky without any bells and whistles.
So, install and launch Terragen.
At the very beginning you will see 2 windows: Landscape And Rendering Control. Let's start with the first one.

1. Landscape window

The Landscape window generates the appearance and terrain of the area.
t8terragen2 First, let's open one of the standard appearances (the Open button in the figure above). We have a small choice, only 5 different surfaces, among which are: "Desert with grass", "Grass and sand", "Grass and snow", "Lifeless desert" and "Red desert".
We chose "DesertAndGrass", i.e. "Desert with grass."
In the same Landscape window, you can slightly edit the landscape relief - make the mountains higher or, conversely, the depressions deeper (the tools that perform these operations are highlighted with a blue rectangle in the figure above). You can also set the relief map to be displayed in black and white or color (the Grays and Cols flags, respectively), but more on that later, because We haven't generated the surface yet.
We can generate the surface after pressing the button Generate Terrain...
t8terragen3 After clicking on Generate Terrain..., the following window will appear in which you can set the parameters of the future surface (highlighted in blue).
t8terragen4 Method
Selecting the method used to create the landscape. For example, the Ridged Perlin and Perlin Noise methods make the terrain appear rockier. The easiest way is to experiment with these settings.
Action
If you want to create a new area from scratch, then select the first item (Erase first and generate...).
Otherwise, a new surface will be created and combined with the existing one.
Realism
The higher the value, the more realistic the landscape will be, the smoother the transitions from hills to valleys, etc. will be. A lower value creates a more rocky (steep) terrain.
Smoothing
Smoothness of the landscape. Setting this parameter too high may result in rendering not very realistic landscapes.
Glaciation
This parameter is responsible for leveling and smoothing depressions (depressions).
Canyonism
Opposite Glaciation, i.e. creates a more angular relief.
Size of Features
This parameter determines the size of hills and elevations, both in area and in height.
After all parameters are set, click Generate Terrain. A surface is created. And now we can edit the terrain manually using the tools described above.

2. Rendering Control Window

In the "Rendering Control" window we determine the position and direction of the camera's view, and also set the quality, detail and size of future pictures.
The first blue rectangle shows the camera coordinates. It is convenient to check the "Terrain units" checkbox, then the central position of the camera will be at X=128 and Y=128 (Z - determines the height of the camera above the ground). Set X=128, Y=128, and Z=any.
t8terragen5 What is not highlighted with a blue rectangle (Target Position) sets the target coordinates for the camera, i.e. the points where she looks. In principle, you can not indicate these coordinates.
But let's look at the next blue rectangle in more detail, but a little lower :) First you need to specify Zoom, which determines the viewing angle of the camera. We need to set the angle to 90° to get 6 pictures of the sky.
To do this, click the button in the Rendering Control window Camera Settings... (circled in red oval).
The following window appears:
t8terragen7 Photographic Medium
Here it is better to indicate the last point to get the most realistic-looking pictures.
Exposure/Light Sensitivity
We leave it unchanged.
Zoom/Magnification
This parameter MUST be equal to 1, otherwise we won't be able to create a sky for Half-Life.
Returning to the main Rendering Control window, click the button Settings...
In the window that appears, set the maximum rendering quality, as well as the Ultra anti-aliasing mode (available only in the registered version).
t8terragen6 Let's return to the picture with the Rendering Control window (see figure below).
Now you need to set the sizes of future pictures. In Half-Life, as already mentioned, sky images of 256x256 pixels are used. However, you can generate larger images, for example, 512x512 pixels, so that more details are displayed on them.
Then such pictures will need to be reduced to 256x256 pixels in some graphics editor (for example, Photoshop).
We move on to the final stage in creating pictures. Now all the properties have already been set, the parameters have been determined, all that remains is to generate 6 images by rotating the camera on the sides by 90 degrees.
Camera orientation is controlled by the parameters indicated by the second blue rectangle: Head, Pitch, Bank.
Bank — must always be equal to 0.
Head — determines the direction in which the camera is looking (0°, 90°, 180°, 270°).
Pitch - vertical viewing direction (90° - straight up, -90° - straight down).
Camera orientation when rendering images
RT (right picture):   Head=0   Pitch=0   Bank=0
FT (front picture):   Head=90   Pitch=0   Bank=0
LF (left picture):   Head=180   Pitch=0   Bank=0
BK (back picture):   Head=270   Pitch=0   Bank=0
UP (top picture):   Head=0   Pitch=90   Bank=0
DN (bottom picture):   Head=0   Pitch=-90   Bank=0
To start the rendering process of the first image, click the button Render Image. The process may take a long time, depending on the amount of RAM, processor power, as well as the size, detail and quality of the future image.
After creating the first image, save it in BMP format (24-bit). Change the Head and Pitch parameters to the following and start rendering the second image.
As a result, you should end up with 6 images of the sky, which must be reduced to 256x256 pixels and converted to TGA format (24-bit).

3. Palate testing

Name the pictures according to the format discussed above. For example, like this:
clearday_rt.tga
clearday_ft.tga
clearday_lf.tga
clearday_bk.tga
clearday_up.tga
clearday_dn.tga.
Create a simple test card. In order for 6 sky pictures to be visible on the map at once, make the floor from a CLIP brush, which will be transparent in the game, and you will be able to see all parts of the sky.
Enter the name clearday_ in parameter environment map, which is in the menu "Map\Map properties...".
Place the pictures in the folder "cstrike\gfx\env.." and launch the map. Everything should work out.