DirectX Texture Editor (dxtex.exe)

Description

The DirectX texture editor (DxTex) enables DirectX SDK users to create texture maps that use the DXTn compression formats.

Compatibility Chart

Direct3D 9 Direct3D 9 EX Direct3D 10 64-bit Native Mode Windows XP Windows Vista

Yes

No

No

Yes

Yes

Yes

Installation

The DirectX texture editor is automatically installed when you install the DirectX SDK.

Source: (SDK root)\Utilities\Source\dxtex
Executable: (SDK root)\Utilities\Bin\x86 or x64

User's Guide

The DxTex tool allows you to open, view, manipulate, and save textures in various formats, and use various texture features. DxTex uses a traditional document-based UI. Each texture map is a document, and several documents can be open at one time.

Opening and Creating Textures

Follow these steps to open an existing texture.

  1. Start the DxTex tool.
  2. Select the File->Open... menu item.
  3. From the dialog that pops up, select a bitmap to open as a texture.

Follow these steps to create a new texture.

  1. Start the DxTex tool.
  2. Select the File->New Texture... menu item.
  3. From the dialog that pops up, specify the options for the texture you wish to create, and click OK.

Converting, Viewing, and Saving Textures

Follow these steps to convert an existing texture to a different format, compare the original and new formats, and save the resultant texture.

  1. Open an existing texture by selecting the File -> Open... menu item.
  2. Select the Format -> Change Surface Format... menu item.
  3. From the dialog box that pops up, select a new format from the drop-down list, and click OK.
  4. To compare the original format to the new format, click on the displayed texture. Clicking on the texture will toggle between displaying the new format and the original format.
  5. To save the texture in the new format, select the File -> Save As... menu item and select a new file name from the dialog that pops up. Click Save to save the texture file.

Note    When changing formats, the original bitmap is used as the source image, and any previous format change is overwritten. This is to prevent progressive degradation of the image that would otherwise occur with multiple format changes.

Using Alpha Channels

Many texture formats include an alpha channel, which provides opacity information at each pixel. DxTex fully supports alpha in textures. When a bitmap is applied as alpha to a texture, the blue channel of the bitmap is used to provide the alpha data.

There are two ways to provide a texture with alpha data. You can use a special file naming convention to notify DxTex to add a specified bitmap as alpha to a texture automatically, or you can add a bitmap as alpha to a texture manually. For both methods, you must have a texture you wish to add alpha data to, and a bitmap that will provide the alpha data to the texture.

Note    Some DxTex operations (Open as Alpha Channel, conversion to DXT3, and conversion to DXT5) are not possible on DXT2 and DXT4 formats. For more information, see the Premultiplied Alpha section.

Automatically Opening Into An Alpha Channel

Follow these steps to open a texture with alpha automatically.

  1. Using Windows Explorer, browse to a bitmap you wish to open with alpha. The second bitmap that will supply the alpha data must also be in this directory.
  2. Right-click on the bitmap that will supply the alpha data, and select Rename.
  3. Rename this bitmap to match the name of the bitmap you wish to apply the alpha to, appending an "_a" suffix to the file name. For instance, if you wish to apply alpha to "flowers.bmp", the alpha data bitmap must be named "flowers_a.bmp".
  4. Open the DxTex tool.
  5. Select the File->Open... menu item and select the bitmap you wish to open with alpha. The second bitmap that contains the alpha data will be loaded into the alpha channel automatically.

Manually Opening Into An Alpha Channel

Follow these steps to open a bitmap as an alpha channel in an existing texture.

  1. Open an existing texture that has an alpha channel by selecting the File -> Open... menu item.
  2. Select the File -> Open Onto Alpha Channel of This Texture... menu item. Select a bitmap that contains alpha data from the dialog that pops up.

Note    If the existing texture is a volume map or cube map, you must select the File -> Open Onto Alpha Channel of This Surface menu item after selecting an appropriate surface in the cube mapped or volume mapped texture. See the Cube Map and Volume Map sections of the user's guide for more information.

Viewing An Alpha Channel

When alpha data is applied to a texture, the texture will display with the alpha channel overlayed. To display the alpha channel by itself as a grayscale image, select the View -> Alpha Channel Only menu item.

Cube and Volume Maps

DxTex can convert textures to cube and volume map textures, and provides the ability to navigate and save these textures. A cube map texture is a collection of six textures that are arranged like the faces of a cube, one texture per face. A volume map texture is a collection of one or more textures arranged in "slices," where each pixel can be thought of as having three dimensions: height and width, which describe the pixel's location on a slice texture, and depth, which identifies the slice the pixel is on.

Creating and Importing onto Cube Maps

Follow these steps to convert a texture into a cube map.

  1. Open an existing texture by selecting the File -> Open... menu item.
  2. Select the Format -> Make Into Cube Map... menu item.
  3. The current texture will occupy one face of the cube map. From the dialog that pops up, select which face you want the texture to occupy, and click OK.

Follow these steps to import texture data into each face of a cube map.

  1. Select the View->Cube Map Face menu item and select a face from the list that appears.
  2. Select the File->Open Onto This Cubemap Face... menu item and select a texture to open from the dialog that pops up.
  3. Repeat this process for each face.

Creating and Importing onto Volume Maps

Follow these steps to convert a texture into a volume map.

  1. Open an existing texture by selecting the File -> Open... menu item.
  2. Select the Format -> Make Into Volume Map... menu item.
  3. From the dialog that pops up, select the number of slices (layers) you want the texture to occupy, and click OK.

Follow these steps to import texture data into each slice of a volume map.

  1. Select the View->Higher Volume Slice or the View->Lower Volume Slice menu item to change the current slice being viewed.
  2. Select the File->Open Onto This Surface... menu item and select a texture to open from the dialog that pops up.
  3. Repeat this process for each slice.

Mipmapping

Mipmapping is a technique that improves image quality and reduces texture memory bandwidth by providing prefiltered versions of the texture image at multiple resolutions. Filtering is done through a simple box filter. That is, the four nearest pixels are averaged to produce each destination pixel.

Follow these steps to generate a mipmap for a texture.

  1. Open an existing texture by selecting the File -> Open... menu item.
  2. Select the Format -> Generate Mip Maps menu item.
  3. Select the View -> Smaller Mip Level or View -> Larger Mip Level menu item to navigate through each image in the mipmap.

Note    To generate mipmaps in DxTex, the width and height of the source image must both be powers of two.

Command-Line Mode

You can use command-line options to pass input files, an output file name, and processing options to DxTex. If an output file name is specified, the application exits automatically after writing the output file, and no user interface is presented.

dxtex [infilename] [-a alphaname] [-m] [DXT1|DXT2|DXT3|DXT4|DXT5] [outfilename]

infilename:               Name of the file to load.  This can be a
                            .bmp or .dds file.

-a alphaname:             The next parameter is the name of a .bmp 
                            file to load as the alpha channel. If no 
                            alpha filename is specified, DxTex still
                            looks for a file named Infilename_a.bmp. If 
                            it exists, use that file as the alpha 
                            channel.

-m:                       Mipmaps are generated.

DXT1|DXT2|DXT3|DXT4|DXT5: Compression format. If no format is 
                            specified, the image will be in ARGB-8888.

outfilename:              Name of the destination file. If this 
                            option is not specified, the user interface 
                            shows the current file and all requested 
                            operations.  If an outfilename is specified, 
                            the application exits after saving the 
                            processed file without presenting a user 
                            interface.

Notes

Creating Textures

Creating a DXTn-compressed texture is not difficult. However, Direct3D can do the conversion for you when using the IDirect3DTexture9 interface. Advanced developers will probably want to write their own tools that meet their specific needs, but the DxTex tool provides useful basic functionality.

Performance

DxTex uses the Direct3D Reference Rasterizer to draw the textures, regardless of what 3D hardware is available. So with larger textures (greater than 256-by-256 pixels), the application may be somewhat slow, depending on your CPU speed.

DDS File Format

See DDS File Reference for more detailed information about the DDS file format.

Note    DxTex does not currently support textures with surface formats that do not contain at least an R, G, and B texture (such as D3DFMT_G16R16 and D3DFMT_A8), although D3DX can load and save such textures in DDS format.

Premultiplied Alpha

The DXT2 and DXT4 formats use premultiplied alpha. This means that the red, green, and blue values stored in the surface are already multiplied by the corresponding alpha value. Direct3D cannot copy from a surface that contains premultiplied alpha to one that contains non-premultiplied alpha, so some DxTex operations (Open as Alpha Channel, conversion to DXT3, and conversion to DXT5) are not possible on DXT2 and DXT4 formats. Supporting textures using these formats is difficult on Direct3D devices that do not support DXTn textures. This is because Direct3D cannot copy them to a traditional ARGB surface either, unless that ARGB surface uses premultiplied alpha as well, which is rare. For this reason, you might find it easier to use DXT3 rather than DXT2, and DXT5 rather than DXT4, when possible.