Hints, tips and tutorials for 3D modelling & content creation
|
KatsBits
Creating 3D models, meshes &
game content
3D modelling & meshing, level editing and textures makingHints, tips and tutorials for 3D modelling & content creation [back]Creating normal maps from images pt.2ResourcesContents
What's this about? ^This tutorial explains in further detail the process of creating a heightTemplate for passing through one of the normalmap creation tools, mentioned in the previous tutorial (though not the specifics of 'how to use' the tools). And creating 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.
Initial layer for size and scale ^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. Depth using layers ^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 normalmap by passing it through one of the bumpmap 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 bumpmap 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 grey, 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 grey 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 grey. You just then need to nudge the objects slightly to expose the thin line. Cross members ^The initial layer used for the cross member supports is the same grey 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º.
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. Adding more more height ^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 grey. 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 normalmap. 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'. Adding fine details ^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 bumpmap 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 heightmap later on.
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. Creating cut out areas^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.
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. Final steps and image template 'prepping' ^The final step before passing this heightTemplate through the bumpmap 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. Photoshop and the gimp ^What you do next depends on whether you have photoshop or the gimp with their respective normal map plugins, 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. Alternative normal mapping tools ^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.
Generating the normal map from the texture template ^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).
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. Adding alpha masks to the texture ^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 normalmap; the two main ways to do this are :
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.
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'. Writing basic materials & getting the texture into game ^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;
And then the whole lot placed in the Doom 3 directory. Hiding in the shadows ^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 modelling the object in question. ![]() render of girder with all layers in place in Doom 3 |