Content is copyright © KatsBits™ 2000-2013. All Rights Reserved.
No part of this web site may be reproduced (except for personal use) without prior written permission from KatsBits.com. For more infomation on copyright click here.
This tutorial explains in further detail the process of creating a heightTemplate for passing through one of the normal map creation tools mentioned in the previous tutorial (though not the specifics of 'how to use' the tools), and how to make masks or alpha channels to 'knock out' certain areas of the resulting image in game.
You will need at least a basic knowledge of how to draw and manipulate shapes and objects in your photo editing suite and be at least familiar with some of the main tools used for image editing (i.e. you need to know what they do rather than being particularly proficient in using them).
The following images show only a section of the final girder texture on which this tutorial is based - the final image is 512 pixel high by 128 pixels wide, this was chosen because it allows a slighter greater amount of 'uniqueness' to be added over the length of the in game image which reduces the amount of visible tiling a shorter section would create.
To get the initial 'scale' of the girder correct two parallel objects are placed onto the page. These not only set out the distance between each other but also the thickness of the main support beam. This base layer is created using a shape 'primitive' although it can be made using any method that will eventually produce two parallel objects of the same width and height; the easiest is to draw out an object and then duplicate it. Make sure the outside edges are butted right up to the documents edge at this early stage otherwise you might find you can't get it to tile or line up correctly in game which will mean you'll have to remake everything to correct it.
Once the initial layer is in place and we're happy with the relative sizing of everything, we can start to build 'height' and 'detail' into the object. As we'll eventually use this image to generate a normal map by passing it through one of the normal map tools, height has to be added in a slightly different way than we're used - we can't use 'baked' light and dark highlights and shadows as would be the case with a normal texture because those will be interpreted incorrectly by the normal map tools. What we have to do instead is use 'layers'; progressively lighter and lighter objects whose tonal values are interpreted as 'height' the closer to 'white' they get (black being as far back as you can go).
Our next object then is a lighter tone of gray, and to create a 'smooth' inner edge transition in the normal map when that gets generated, it's offset by 1 pixel leaving a thin 'line' of darker gray from the object underneath it exposed. You can create this layer in a number of ways but the easiest may be to duplicate the initial layers and flood fill with a lighter tone of gray You just then need to nudge the objects slightly to expose the thin line.
The initial layer used for the cross member supports is the same gray as the previous layer and as it sits on top of that 1 pixel inner edge created above it'll result in a nice little 'emboss' there as if it was welded onto the main struts.
The easiest way to create 'angled' objects like this is usually to draw out a simple line or block to the correct thickness, making sure you allow for plenty of overlap, and then 'turn' or 'rotate' the object by a certain number of degrees - in this case 45º.
Design note : it's worth pointing out here that when you rotate objects like this you introduce a 'pixel stepping' artifact into the image, usually along the edge. This is because the anti-aliasing used by the photo editing program can't 'smooth' the edge to make it cleaner. There's not much you can do to fix it and still get a clean line or edge as any blurring or feathering work often results in a soft edge which may not always be desirable.
Incidentally this is one of the reasons why it's preferable to model and then render a high resolution 3D object because rendering can be set to use various degrees of image 'over-sampling' to smooth out angled or non-linear lines, features and edges.
If you then copy, duplicate and mirror the object you should be able to then place both 'halves' together to create an 'X' shape - drop in a guideline if you need to so you can align them correctly to each other. Once this has been done they can be moved into position and centred between the upright struts. Because this layer is the same colour as the previous layer and overlaps don't need to be removed.
Now the the basic structure is sorted out and the cross members positioned so they tile when the texture is stacked we can move on to the details.
For this texture the girder uprights need more height so they basically stand out further than the cross members (the cross member need to 'appear' to be further back or behind the main uprights), so an object is added to another layer and flood filled a lighter tone of gray It's a couple of pixels thinner than the previous layers - how much thinner depends on the 'look' you're going for - in this particular instance, approximately 1 pixel thinner so it reveals the darker tone of the underlying layer; as mentioned above this will add some overall 'height' to the normal map
The main struts could now do with a little bit more height to set it above the previous layers making the cross members appear 'recessed'.
Now that the basic structure of the girder has been laid out in the previous layers, we can begin to add 'details' to the image using various objects building up the depth layer by layer. What you do here depends on the 'look' you're trying to achieve but keep in mind that the purpose of this image is to provide the base template from which the normal map will be generated; we only need information pertaining to what the object is and not what it's made of, i.e. the surface information ('rusty steel' for example), that's done using the height map later on.
Design note : keep in mind whilst you work that you don't really want to use features smaller than 1 pixel in width or height too much as invariably details that small tend not to convert too well into normal maps; the detail is so small it generally gets 'lost' in the conversion. Features like rivets tend to be OK because they're usually object sat on the very top layer and in 'isolation' (that means the tools can see them more clearly).
The forth layer above in this instance gives us the 'finished' object in terms of it's general features; 'pressed' metal shaped for increased strength and rigidity that flat metal doesn't have.
Now depending on if at this point you're happy with the object as it is, you can go on to add 'cut-outs' - in real life these are where waste metal is removed in such a way as to reduce the objects overall weight without effecting it's strength.
The trick here is the uniformity of the cut-outs, they all have to be the same (unless you want damaged objects or are going for the damaged/old look); if you try to do that by hand using the eraser tool you won't get the accuracy needed. To get round this what you do is create a shaped 'template', a mask tool', that can be duplicated, rotated and moved without loosing detail.
The easiest way to do one of these templates is to draw out a primitive shape (square, rectangle, circle, etc.) and edit it so it looks like that kind of cut-out you want; in the case of this tutorial girder that template shape is a simple square with slightly rounded corners.
Design note : placing guidelines helps to align each instance of the template object.
Because the cross braces are at an angle the template was rotated to the same angle and placed so it covered part of the underlying layers - for this to work the template is on the top most layer but it can be on any layer depending on the effect you're after.
Once you've got the initial template positioned as wanted, rinse and repeat over the whole texture.
The final step before passing this heightTemplate through the normal map tools is to create or 'flood fill' the background (how you do that depends on how your photo editor works) with black or the darkest colour you need in order to get the depth required; relative to the rest of the image; in this case 'black'.
Once you've done this the image is basically finished for this stage of the process. So if you haven't already done so, save a copy or version of the file with the layers intact; do not flatten the working file.
You should then end up with two files, the one you have open - saved as 'girder_1' for instance - and a copy saved as 'girder_2'. Doing this serves several purposes but primarily for practical reasons it means you have a backup if you accidentally re-save the working file once it's been flattened, overwriting the previous version.
What you do next depends on whether you have photoshop or the gimp with their respective normal map plug-ins, if you have either of those you just need to flatten the image and process it with the filters to produce the localised colour image. Save that as either a native file format (*.psd for example) or as a 24 bit *.tga. If you don't have photoshop, the gimp or a way of processing normal maps 'internally' (from within your photo editor) then you'll need to export the heightTemplate to a format one of the external normal map tools understands; usually that's *.tga. As above simply flatten the image and then 'save as' or 'export' to 24 bit *.tga.
Design note : to make sure the document only contain grayscale colour values, just before final save or internal processing convert the document to 8 bit grayscale and then back into 24 bit colour. Doing this ensures that the template only has 'pure' grayscale values in it.
The exact details of 'how to use' any one of the normal map generators won't be covered here because they do vary quite a bit so suffice to say you now need to pass the image template though one for processing at the end of which you will end up with an image that's coloured in pure 'RGB' giving the distinctive blue/pink/green coloration. These colours form the visual representation of the 'normalised' pixels contained in the image (or polygons if it were a 3D model).
Design note : if you think the image is too big it's best to re-size the heightTemplate rather than the resulting normal map after it's produced, not doing that can introduce 'artifacts' into the normal map (although you can run the image through the nVidia photoshop plug-in and 'normalise only').
Once you've got the normal (local) map generated, for most textures this would be the end of the process (aside from then creating the diffuse, specular and height). But, because this is a 'girder' it needs to looks like it's constructed from long lengths of metal with cross braces. To do this the texture needs an 'alpha' channel or 'mask' to remove the unwanted material from the image when it's in game.
Exactly how you do this again depends on how your photo editing application creates 'masks' or 'alpha channels'. The easiest thing to do in this particular instance is to make use of the shapes we have on the image itself; if you go back up to the final stage above where the background was filled 'black', that can be used to our advantage in instances like this.
So pull up the working file again (it can be the layered or a flattened version, it doesn't matter at this point), and make sure the background is black and there aren't any gaps or holes. You then need to select the ' magic wand' mask tool (the tool icon for this one usually looks like a little 'wand' regardless of which editing app you're using) and select all the black areas. You may need a key combination to be able to select multiple areas (shift + click) and if you find the tool selects everything it probably means it's 'sensitivity' is set too high, so turn it down until it's only selecting the black areas.
At the end of doing this you should end up with the following; the 'dancing ants' around the borders of the black areas, and when 'paint on mask' is active the actual girder area needed highlights red (as shown above). This then means the 'mask' is 'protecting' the bits needed and allowing the game to remove the areas we don't want (black).
Once the mask is in place it needs to be applied to the normal map; the two main ways to do this are :
Simply copy/paste the normal map image over the top of the mask template (which always tends to sit on top of everything).
Save the masked template to another file ("girder_mask" for example) and then 'load' that in on top of the normal map image - your photo editing app may actually allow you to save an image as a mask rather than just saving as another version of the same file which just happens to have a mask on it, there is a difference between the two (the option to save as mask will most likely be in the 'mask' menu).
Make sure the mask is seated correctly on top of the normal map otherwise you'll get gaps where you don't want them in game; a quick way to check the texture is to just copy/paste the selection into a new document, this will quickly reveal any alignment or mask errors. Once you've done a quick check flatten the file where applicable so you have just a single layer with a mask channel and then export the results to 32 bit RGB *.tga.
Design note : the 32 bit image being used here is actually 24 bit RGB with an extra 'channel' being used for the mask. It is not the same as a 32 bit CMYK image.
If you don't or can't get a specific file save or export option that allows saving to 32 bit TGA you might find that your photo editing package will instead simply ask if you want to 'save the mask' with the image file, if this is the case say 'yes'.
As this tutorial only deals with the creation of the normal map the details of getting this into game won't be covered here other than to say the mask needs to be 'duplicated' on the diffuse, specular and height (if being used) images; a special material file ('shader' as they were called in Quake 3) then needs to be written to tell the game what it needs to be doing, typically as follows;
//steel girder
textures/supports/girder
{
qer_editorimage textures/supports/5_v2fb_diffuse.tga
// noshadows
twoSided
{
blend bumpmap map addnormals( textures/supports/5_v2_local.tga, heightmap( textures/supports/5_v2fb_h.tga, 4 ) )
}
{
blend diffusemap map textures/supports/5_v2fb_diffuse.tga alphaTest 0.5
}
{
blend specularmap map textures/supports/5_v2fb_s.tga
}
}
And then the whole lot placed in the Doom 3 directory.
A quick note here on shadows. These types of textures cannot and do not, by default, cast shadow volumes; the use of alphaTest disables that ability so if you wanted shadows you'd need to do a bit of work adding extra brushwork to the objects covered in the 'shadow' material (so the brush object doesn't appear in game but it does cast shadows) or by modeling the object in question.
Render of girder with all layers in place in Doom 3
There's little difference in 'technique' between the methods used to produce artwork for the various games that make use normal maps to 'fake' depth in game to the tutorial information below, which was originally written for games powered by id software technology; in other words, you can use the same method described below and have a working normal map at the end of the process.
There are however, a couple of things that you must check;
RGB orientation
RGB orientation is quite important, if you get the colour channels (R - Red, G - Green, B - Blue) the wrong way around it'll effect the appearance of the texture in game; it'll be flipped or inverted. Getting this wrong won't break the game it just means a bit more work to fix it, which thankfully it is relatively easy to do by simply flipping individual channels until the texture renders correctly in game.
How the alpha channel is used (if any)
Regardless as to what any given games does with the alpha channel (mask layer) in game, it's usually used as a 'mask' of some kind; it tells the engine to use the 256 tones of gray to do 'something' to the texture relative to black/(gray)/white.
For the Doom 3 engine it's used as an actual 'mask'; it knocks out (removes) sections of the texture from being rendered. Other game engines most commonly it's used as a 'specular' layer; the mask effects the 'shininess'' of the image in game - a worn metal plate for instance, might have shiny edges where it's been held which over time will smooth out and become shiny.
Depending on the game, the mask layer could also be used for parallax mapping which means the same gray scaled tones effecting the increased depth that parallax mapping offers instead of specular highlights.
It's important to check these two features at least, simply to save you the extra work of correcting errors after you find a batch of artwork is the wrong way around!
Because Quake 4 runs on the Doom 3 engine it means that everything to do with the texture creation process for Doom 3 applies directly to Quake 4; that means you can use exactly the same height (bump) maps, normal maps, diffuse and specular maps in both Doom 3 and Quake 4.
This also applies to the methods used when creating textures; anything you've already read about, either here at KatsBits, or elsewhere, can be applied to texture making for both games.
Learn Blender 3D - learn to make a simple low-poly rigged and animated character
Blender & IMVU furniture - new to Blender? IMVU? Learn to make furniture quickly
Displaced Terrain Mesh - using displace to make a basic terrain +optimisation tips
Displace & Simple Terrain - making a simple terrain in Blender 2.49 using displace