Crrrazydan's DDS Tutorial - Making DDS textures for use with TrueVision

This tutorial was originally written by Dan Krueger. I copied it from his site
http://www.snowboardassassins.shorturl.com/
All credit of course goes to him.


Written 01/13/03 by Dan Krueger

A lot of TrueVision 3D Engine users seem to ask about how to make a DDS texture, so here is a tutorial on how to make and use them.

1) Why DDS?

So what exactly can a DDS texture do? It allows you to have smooth textures with varying levels of transparency. Even if you don’t need any part of your texture to be transparent, such as lettering, I would still suggest using DDS. Or at least TGA or PNG, some format that allows transparency. That way you wont have any hard edges or color scraps left over by insensitive colorkeying. Every single thing drawn on the screen in the picture at right is a DDS texture. The fence, the falling snow, the trees, and the snow-machine particles in the background are also textured with DDS.

My image editing program of choice is Adobe Photoshop, but you can create great DDS textures with any nice image editing package such as Paint Shop Pro, or The Gimp (which is free). I compile the DDS textures in the DirectX Texture Tool - dxtex.exe (downloadable here - 492kb), which comes in the DirectX 8 Visual Basic SDK. There is a DDS exporter you can download from nVidia for Photoshop, but I and many others find it too confusing.

2) Surface image

There are two images, or “surfaces” that make up a DDS texture. The surface map, and the alpha channel. The surface is the colored image you actually see in-game, and the alpha channel is a grayscale (black & white) image that controls the transparency. Alpha-blending = Transparency. For significantly higher speeds and fewer bugs, always create textures in “power of two” dimensions, this applies to any texture format. Power of two simply means the width and height are each a power of two, such as 256 x 256, 64 x 8, or 128 x 512. The thing that requires the most getting used to with the DDS format, is you have to “let the alpha channel do all the work” -that’s what I always say. I will use lettering for an example. Unless you know what you’re doing, don’t worry about the shape of the letters one bit with the surface image. The image below will show you how the alpha image and the surface image work together.

3) Alpha Image

The alpha image ability is where DDS textures come to life. Here is where you cut the contour and shape of the texture out. The areas in black will be removed, and anything gray-ish will be translucent. If you are making a texture with the purpose of hiding the edges of the texture, here is where you would apply a gradient or feathered brush to the edges of the texture, gradually fading the boundaries out. An example of this is particles or cloud textures. Take a look at the snow particles from Snowboard Assassins:

4) Compiling

With dxtex.exe (downloadable here - 492kb), compiling a texture is easy. Just open it up, click new texture, and input the dimensions of your new texture. Then open your surface texture onto the surface, and open your alpha image onto the alpha channel. Then click Save As. One thing to note- when saving a texture in the DirectX Texture Tool, be sure to type “.dds” after your filename, as it seems to not do that automatically for you.

In TrueVision, make sure to load the texture with the colorkey arguement TV_COLORKEY_BLACK. You shouldn’t need to mess with any of the blending modes, but one thing you most likely will have to do is turn AlphaTesting off. To do that use the line: TVMesh.SetAlphaTest False

And that’s all it takes to make a nice DDS texture! Once you get the hang of it, you can line up your surface details with your alpha details, to make effects like the shadowing on the trick info letters in the above screenshot, or the HUD background I have. Now you can say goodbye to ugly colorkey remnants forever, and enjoy clean, crisp, and optionally translucent textures!

-Crrrazydan

 
tutorialsarticlesandexamples/making_dds_textures_for_use_with_truevision.txt · Last modified: 2007/07/30 18:38