Download (direct link):
A texture most commonly consists of five separate images. Each of these images is referred to as a map because each maps out a single aspect of an image. These maps include
^ Diffuse map: This is the color that will be shown in the texture. Generally, this is the actual image without any changes.
^ Specular map: This defines the way light reacts to the texture. Parts of a texture can be more shiny than others, and this fact is important in the game world where light and shadows occur in real time.
^ Normal map: This defines the way a texture appears to bump out or in. The bumping effect made here can actually affect the polygons upon which this texture is applied.
^ Height map: Although very similar to the normal map, this image creates the illusion of bumps on a texture. This image should be used to create only scratches, chips, or other small bumps rather than larger, more complex ones.
^ Editor image: This is the image that is defined for use within the mapping editor. Without this image, you won’t be able to see and apply your new texture to any surfaces within the game.
To tie all these images together, you will finally create a shader file. This is a text file that defines the location of each of these images and which image is to be used for which purpose.
Chapter 15: Creating Custom Textures 247
Installing Some Tools
Before you get into making your own textures, you need to install some tools for the job. The first thing you need is image-editing software. Something as simple as Windows Paint won’t suffice. You need a program that can open and edit Targa (TGA) images. Targa is an image format used in Quake 4.
For the purpose of this chapter, I use Adobe Photoshop. This professional image-editing program, which also comes with a free trial, has been provided to you in the media located in the back of this book. If you haven’t already, I recommend installing it following the instructions provided on the CD.
The second tool you need is a special filter plug-in for Photoshop called the NVIDIA Photoshop Plug-ins. This filter takes one of your images and transforms it for use with your custom texture into what is called a normal map. This is explained in more detail later in this chapter. For now, just know that you must install it to complete your texture. You’ll find a copy of the installer on the CD in the back of the book.
Finally, the third tool is a conversion utility called The Compressonator. As the name implies, this program reads the images you create for your texture, and then compresses them into a more efficient form for the game. This, too, is explained later in the chapter. Install this tool as it is found on the CD in the back of the book.
Bricking Up the Joint
I was able to take a picture of a wall that will work well as a texture. In Figure
15-1, you can see that my picture has well-defined features. There is nice contrast between the bricks that are sticking out and the joints between the bricks that sink in. These aspects should make for a good texture.
Any image can be turned into a texture. You don’t need to choose one with contrasting highs and lows. This brick picture was chosen to make it easier to illustrate the methods used in making a custom texture.
If you have your own image that you would like to use, open it in Photoshop now. Otherwise, use the same brick image titled Brick_Image_Origmaltga that I have provided on the media located in the back of the book.
Start the Adobe Photoshop program as you would start most of your programs from within Windows — choose StartOAll Programs^ Adobe Photoshop.
248 Part IV: Going Beyond the Basics
If your picture is level and has a lot of detail, this will be reflected in your final texture.
After the program has finished loading, open Brick_Image_Original.tga. Choose FileOOpen, locate the file you want to open in the File Explorer window, and then press Open.
Finding the Right Size
To begin making your custom texture, you need to determine the final size of the image. Quake 4, as well as most games, requires that the width and height of your image in pixels evaluates to a power of two. Basically, this means that your texture must be some combination in width and height using, but not limited to, the following numbers:
8; 16; 32; 64; 96; 128; 256; 512; 1,024
The reason for the size restriction is that the game needs to be able to resize these images while you’re playing the game. The images will be scaled down to half or quarter sizes, and the game can do this only if the sizes can be divisible by two or four.
Chapter 15: Creating Custom Textures 249
While you’re playing, the game displays smaller or larger versions of the same image, based on your distance away from the textures. This is called Level of Detail (LOD) and helps to reduce the amount of computing power required to display all the imagery on the screen at once.
When determining the size of your texture, you need to consider two things. First, you don’t want to take up all the computer’s memory with one texture. Each texture in the game is loaded into your memory before the game starts. If the file sizes of your textures are too big, the game could run out of memory and crash. Second, there is no reason to make a texture larger than what will be used within the game. That would be like buying an 8 x 10 photo for your wallet — it’s a waste of space.