Back to tutorial index page

Stuff with holes in...using nodraw

As discussed in a previous section of these tutorials, Q3 uses shader scripts to create special effects with textures. In very simple terms textures are blended together or manipulated in some way to create the required results. The Q3 Shader Manual offers the definitive guide to writing shaders, and in a later section of this series we will cover how to add your own custom shaders and textures to maps. Sometimes using a shader to achieve an effect is far easier than creating complicated brushwork. One of the best examples of this is grates or fences. Examine fig.1 below. Shaders are identified in GTK by a white border around the texture and [] around the texture name. Remember the image in the editor is only a representation as far as shaders are concerned. The grate shader used below looks solid in the editor, only in game are the transparent parts visible. Because of this it is necessary to have some idea of what each shader does before you can use them.

fig.1

To create the grate over the lava with brushes would be complicated. Instead a shader has been applied to the top face of a brush made out of common/nodraw (fig.2)

fig.2

The common/nodraw texture is used where you don't require certain faces of a brush to be drawn in game. Nodraw must not be confused with caulk, it is not solid and does not block vis, in game it does not exist. Because nodraw is not solid a playerclip brush needs to be placed over the grate, to stop players and bots falling through (fig.3).

fig.3

An alternative approach to achieve the same result would be to simply texture one side of a playerclip brush with the grate shader. Some shaders for textures with transparent parts allow light to pass through and will cast interesting shadows on surrounding geometry. By assigning a _lightmapscale value to surrounding geometry it is possible to sharpen the shadows and make them far clearer. This can be seen on the far wall in fig.1.

fig.4

Above in fig.4 is another example of a use for nodraw. Only the outward facing side of the flag is required. The flag shader has transparent areas rather like the grate shader.

fig.5

Just a mention about the lava placed in the floor trench under the grate (fig.5). Lava is a liquid, so far as Q3 is concerned. It is placed in your map in the same way as water, or any other liquid. Bury the sides of your lava in the surrounding brushes, or apply the nodraw texture. Lava automatically inflicts damage on the player or bot if the hapless individual should be careless enough to fall in. The lava textures can be found in the liquids folder. Each lava texture emits a certain amount of light. In the sample map it is these light emitting qualities, shining up through the grate, that were of primary importance.

Getting custom textures and shaders into your map and how to create terrain areas

Sometimes you may feel it necessary to use your own, or somebody else's textures or shaders in your levels, rather than re-using the standard id texture sets. In order to create the rocky terrain included in the sample map, it is necessary to add new shaders and textures to our collection. Creating textures and shaders is a separate series of tutorials in itself and will not be covered here, but rather how to get your custom content into the game. If you use somebody else's artwork you must remember to give credit in the final build of your .pk3 (how to create a .pk3 is covered later). As individual custom content is not available to all Q3 players, it is necessary to include those files for distribution with your map. A level with a high amount of new textures and shaders can quickly increase the final file size of your .pk3. Balancing the size of your final file with the quest for an original look is something most mappers have to do. One of the most often made mistakes by new mappers is to fail to include custom material. Missing textures in game are rendered as black and white squares.

So how is it possible to get new textures into Q3? Quite simply, locate the texture folder under the baseq3 folder. Into the texture folder place a new folder. It is good practice to name the folder mymapname, where mymapname is the name of your level. Into this you place the textures you want to use in the level. The exact details concerning Q3 textures will not be discussed here, other than to state that they must be either .jpg or .tga. By placing all your textures in one folder, you make it less likely that something will be missed out of the .pk3. Inevitably textures are drawn from several folders, but it helps to be organised.

New shaders are added to the scripts folder, which can also be located in the baseq3 folder. A shader is a .txt file, renamed so that the file extension reads .shader rather than .txt. A word of caution about shaders: Do not edit existing shader files, by doing this you will mess things up. If you want to tinker with a shader script, copy and paste it into a new file, and rename it. In order for the new shader to be found by GTK you need to look for a file called shaderlist.txt in the scripts folder. Open this file and add the name of your shader to the end of it (with out the .shader extension), then save the file.

The latest build of the map compiler (Ydnar's Q3map2) has many useful features. One of these features is the inclusion of a texture blending feature. By using a shader script for the textures it is possible to achieve a gradual blend between textures. The blend is controlled by brushes textured in a special alphaMod shader. The alphaMod shaders and associated textures are distributed with Q3map2, with instructions on where to put them. The gradual blending together of textures is ideal for reproducing realistic rock or terrain features, where mineral or organic material blends naturally into itself, with no abrupt beginning or end. Fig.1 below shows the cave area in the sample map, demonstrating blended rock textures. In this section of the tutorial how to quickly create brushes that replicate rock will be covered, and also how to use the alphaMod brushes to control the texture blending.

fig.1

fig.2

Fig.2 above shows the cave section modelled in GTK, with the rest of the map filtered out. The image in fig.1 shows natural looking rock, so what's with all the green and black squares? That's simply the 'in-editor' image. Where more than one texture blend shader (each shader offers  the opportunity to blend two textures) is used, it makes life easier to use simple editor images, rather than detailed textures.

fig.3

The cave started out as a single wall template, pictured in fig.3 above. The next step is to alter the template to make it appear more organic.

fig.4

So far in this series of tutorials we have used the clipper tool to carve brushes into shapes. To create our rock wall the easiest approach is to use edge manipulation. Select one brush of the template (manipulating all 3 brushes at the same time will have strange results), face on, as in fig.4, left click and hold Ctrl on the left hand side of the brush. Drag the mouse left in a straight line, the brush should 'warp' and follow the mouse drag, then drag downwards. In the above image the brush has been dragged 8 units to the left and 16 units down. Now repeat the same process with the remaining 2 brushes. Next flip to top down view. Select 1 brush, and Ctrl left mouse button and drag the brush left again. Now pull the left edge forward, as shown in fig.5. Don't panic if the warping goes wrong, Ctrl Z is the 'undo' short cut. Repeat the manipulation on each brush.

fig.5

Clone the wall section and place it next to the first section, as shown in fig.6

fig.6

Manipulate the new brushes so that they join together as depicted in fig.7. The left hand top edges need pulling up level with the top right hand edges of the original brushes. From top down view, the left hand side of the new brushes can be pulled back so that they are level with the right hand side of the original brushes. When you come to fill in the floor area, in most cases its best to keep things flat, cut the floor brushes around the angled walls so that there is no overdraw, edge manipulate or clip the bottom of the brushes straight to make things easier for yourself. Be careful though to keep verts (the brush corners) on the grid, otherwise aligning brushes gets very messy, if not impossible.

fig.7

You may be thinking those angles look very sharp, not at all like the smooth edges of real rock. Another feature of Q3map2 is 'Phong shading'. This is a handy tool to be able to use. Phong shading applies soft shadows to geometry, with the effect of making  sharp angles looking rounded. To utilise phong shading, it can be applied to the entire map by setting a key and value during the light compile stage, or as done for the sample map, by adding the line:

q3map_shadeAngle 179

to the shader script for the rock textures. The value 179 is the amount of shadow applied.

Let's turn our attention to the cave roof. The section shown in fig.8 demonstrates how brushes should be cut to follow the contours of the front of the  top edges of the wall brushes. The centre of the top wall brushes is lower than the edges. This means the centre of the roof brushes also needs to be pulled down in order to achieve a perfect fit. To pull down the edge of those brushes vertex editing can be used. This is shown in fig.9. Select the brushes and press v to engage vertex editing mode. Carefully select the verts you want to move and drag them down into position. A ceiling or roof that undulates, varies in height, helps achieve that 'natural' look, rather than having the roof meeting walls at 90 degrees.

fig.8

fig.9

Fig.10 shows where the wall section have met at the corners of the room. Generally it would be a good idea to avoid a right angled corner, as this would not often occur in real caves. That said, in this case it was necessary to fit the cave into a certain area, so a right angled corner was unavoidable. The corner brushes have been clipped and vertex edited into position. As mentioned before, it is always a good idea to run brush clean-up after vertex editing brushes.

fig.10

Having modelled the cave the next step is to use the alphaMod brushes in order to create a blend between the base texture and blended texture used in the rock shader. Select the common/alpha_0 texture. Draw out brush volumes made from this texture and place them over the cave brushes at points were vertices meet where you want blending to occur. Fig.11 shows an example of this. For further, more detailed information, visit Simland, Sock's excellent series of articles discuss, amongst other things, rock wall creation and phong shading.

fig.11

One last job to do. In order to prevent players getting snagged on our rocky out crops and to make the way simplified for bots it is necessary to fit  clip brushes over the top of our cave. This is shown in fig.12, where the rest of the map has been hidden from view. The orange and white clip brushes are weapclip. Not only does weapclip block players and bots, but also causes weapon fire to impact. By having a simplified cave area made out of weapclip, passage is made easier for players and bots and collision calculations are made easier for the computer.

fig.12