Jump to content

Guides/DDS compression with DirectXTex

From HEModdingWiki
Revision as of 22:57, 10 January 2025 by LightningWyvern (talk | contribs) (Unfinished DirectXTex tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

DirectXTex is a set of 3 programs that are essential for doing any sort of manipulation of DirectDraw Surface textures.

This page will briefly detail both basic and advanced usage of these tools.

The three tools in this set have seperate purposes.

  • The main tool, texconv, is simply for converting textures to and from DDS, or for changing the format of DDS files.
  • It also contains texdiag, which can be used to analyse DDS textures to find out the format and other metadata.
  • Lastly, texassemble is for constructing DDS textures containing multiple images, such as cubemaps, volume maps or arrays.

Basic Command-line Usage

DirectXTex tools are only operable through the Windows Command Prompt, so first we must understand how to operate the command line.

The window has a line with the current selected directory, waiting for user input.
Command Prompt window upon opening it.

First, open up Command Prompt (you may need to use the search bar). You will be met with a screen like this.

The input line tells you the current selected directory, which by default is your user folder. To run any DirectXTex tool, it is best to navigate to the directory which you have the tools stored in. To change the active directory, you need the cd (Change Directory) command. Enter:

cd <filepath-to-directxtex>

Make sure to replace <filepath-to-directxtex> with the actual filepath, without the angle brackets included. If the tools are on another drive, e.g. D: or E:, you may also need to switch to this drive by simply enter the name of the drive. For example:

D:

Once this is done, you should be in the correct directory, ready to run the tools. You could test this by typing the name of the tool's exe (without the .exe extension) and it should show you the tool's help menu:

texconv

Using texconv

At minimum, texconv must take in one filepath as an input. By default, it outputs a DDS with some variation of B8G8R8A8_UNORM, depending on the input file.

texconv "D:/My Textures/texture.png"

You can also convert all the textures in a certain folder by using the wildcard (*) character, and you can select an output directory with the -o input (Note: the output directory path cannot end with a /).

texconv "D:/My Textures/*.png" -o "D:/Converted Textures"

Texture Formats

The textures output with the default command work fine for most cases, like basic character or stage textures, but may not work correctly or at all for specialised cases like heightmaps or skycubes, and usually ends up with an unnecessarily large file size. To solve these issues, setting image format is required.

Image format can be set with a -f input, followed by the name of the format.

texconv "D:/My Textures/texture.png" -f BC7_UNORM

BC7_UNORM is generally the most compatible format, and has good compression. However, other formats may be required for other purposes. A list of the used formats can be viewed on the texture resource page.

Using texdiag

Unfinished

Using texassemble

Unfinished