fps.gif (3966 bytes)
Textures4

transparent.gif (893 bytes)FPSNews Up

Up
Texture1
Textures2
Textures3
Textures4
Textures5
Textures6
Starfeild Shader

Qworkshop3 Tutorials

Custom textures 4. Skies

 

The sky shader in q3a are made pretty much like any other shader. The differences come down to a few lines in the shader script that alter the behavior of the texture significantly. A typical sky shader is made from two components. A 'farbox' and at least one cloud layer. Most sky shaders in q3a have two or three cloud layers. You can have up to eight but that would put a serious demand on the processor, or none like in the space maps. The farbox isn't necessary if the outer cloud layer is not transparent. It is also possible that a 'nearbox' can be added, but this feature seam to be a relic from the past and is not used in the game.

The farbox is a cube made from six textures, and it is always centered on the player. Do not mistake the farbox with your sky brushes. The sky brushes only define where the sky is visible. The farbox and the cloud layer will always appear to be the same distance away from the player. One way to use the farbox is to have big textures (like 256*256) with a landscape or a starry night sky on them. Another is to use small textures filled with one color, to provide a background for the clouds.

The cloud layer (or layers) is drawn as on a sphere. Now, if you have a farbox, the bottom of the skybox will be drawn properly. If you do not, then the bottom will get the HOM effect. So, when using only cloud layers, the bottom of the skybox must be kept from sight. And like I said, trying to move the sky brushes wont work. You probably know this already.

Farbox Script

This script draws a farbox without any cloud layers. For a full(er) explanation of the keywords and commands, get Id's official shader manual.

_________________________

textures/papas_stuff/bongosky

{
qer_editorimage textures/papas_stuff/bongosky.tga
surfaceparm noimpact
surfaceparm nolightmap
q3map_globaltexture
q3map_lightsubdivide 512
q3map_surfacelight 100
skyparms env/bongo 256 -
}
________________________

The first line two lines we know from the previous tutorial. The editor image is actually the cloud layer image, but its not used else where in this script, yet. The next two lines are surface properties; 'noimpact' means that weapons will not hit this surface, i.e. no marks or explosions. 'nolightmap' makes it so that light or shadows are not drawn on the surface.

The following three lines are commands for the compiler. 'q3map_globaltexture' somehow improves how the shader looks/works when drawn over several brushes. I am not sure it is needed until we add the cloud layer. 'q3map_lightsubdivide' defines how large the triangles of the textured surface are. Here we have set it to 512 game units, which is quite large. I believe this results in less precision in the calculation of the lightmap as far as the light from the sky is concerned. But it is said to be faster, default is 120. 'q3map_surfacelight' defines how much light the surface emits. Since the sky is rather big, 100 is enough for me (500 or so should be like daylight). The color of the light is calculated from the textures. The light seems to be calculated from the actual brushes, so moving the sky away from the player will dim the light around him.

The last command, skyparams sets the textures for the farbox, the height/curvature of the clouds and possibly the textures for the nearbox. 'env/bongo' is the directory and the first part of the file name for the six textures needed for the farbox. The second part of the file name specifies which side is which. In this case, they should be named like so:

bongo_up.tga (up), bongo_dn.tga (down), bongo_bk.tga (back), bongo_ft.tga (front), bongo_lf.tga (left), and bongo_rt.tga (right).

These are the files q3 will look for in the /env folder if skyparams is set to env/bongo. 256 is the height of the box, and the '-' means that we wont be using a nearbox. If you don't have a far box either type '-' instead of the env/bongo part.

For this tutorial I have decided to make a plain natural sky, so I made six 16*16 24-bit TGAs (and named them as above) filled with only a light blue color. (Pk3 file below.) If you put them in the /env directory and load up a map made with the shader shown earlier, you will get a plain blue farbox for a sky.

 

Cloud Layer

Blue is nice, but kind of boring and cloud layers are actually the important part of this tutorial, so lets add one.
__________________________

{
map textures/papas_stuff/bongosky.tga
blendFunc add
tcMod scroll 0.05 0.06
tcMod scale 3 2
}
__________________________

When you add this stage to the fist script, Q3 will load the image bongosky.tga, blend it with the background and then continually modify its placement. Tcmod modifies texture coordinates. Here we use two functions scroll, that moves the texture, and scale that changes its size. Try adding 'tcmod rotate 5' or changing the values up and down. to see what they do.

The 'blendfunc add' is the most interesting keyword in this stage. It adds the color values of each pixel in the image to the background. So, because our farbox is filled with a rather bright blue, the cloud image (bongosky.tga in this case) can be rather dark, and still produce white clouds. 'Add' is actually a shortened command to make life easier for us. The explicit blendfunc commands are a bit trickier to understand. The two other short commands available are 'filter' and 'blend'. Blend does that alpha channel trick used for grates (and thus requires a 32-bit TGA to work), and filter removes colors from the background. These could also be used for making skies. Try them out and see what happens.

Making a good sky can be rather tricky. More often than not you end up with something out of a LSD trip. The images you use for the clouds, and more importantly, a farbox, must tile seamlessly. If they don't, it will be easy to see where one texture ends and the next begins and this completely destroys the illusion. The farbox will look like, well a big box.

I have made a pk3 file for you. It contains the sky shader we made here as well as another one with a slightly more colorful farbox. Put it in your baseq3 directory, add 'bongosky' to the shaderlist and load the papas_stuff directory in q3radiant to use them. Then brake them apart and mess them up!

(Also, take a look at the original skies shader file. You will notice that most shaders do not use a far box, but an un-blended cloud layer.)

 

Papa Bongo

 

 

Hit Counter

 

Bill Brooks © 1999
email contact: Bill Brooks