Texture Compression

Comparison of texture compressions

DirectX games use .dds texture files. For most purposes, these texture files are compressed to decrease their size and therefore video memory usage. In return, compressed textures also have slightly decreased quality. There are different compression types, one of the most common one is DXT (BC1-3). DirectX 11 and newer versions also support improved compression formats such as BC7, which supports grey colors and gradients without discoloration, while its file size is identical to DXT5 (BC3).

In some cases, DXT loses color information, which is especially noticeable with grey colors. For example, here is a comparison of 16x16 pixel textures, one compressed with DXT and one as an uncompressed ARGB texture with 8 bit per channel (A8R8G8B8 in OpenIV).


Please note that the size of dds files cannot be compared to the size of a .ytd texture file directly, as .ytd files are packed texture archives, similar to .zip files. The size of .ytd does not relate to the actual video memory required.



DXT Compression
Uncompressed (A8R8G8B8)
Image
Size
464 Bytes 1472 Bytes
RGB Color Code
66, 63, 66
63, 63, 63


As slightly visible in the images of the textures, the DXT .dds file is slightly pink, while the size is a lot lower.

When should I compress textures?

In almost all cases, especially when using a large number of textures or high resolution textures, DXT is the better option. However, for specific parts, exact colors may be necessary. In that case, the best option is to use uncompressed textures, but at low resolutions to keep the size of the file low. If uncompressed textures are used for too many textures, in particular large ones, disappearing textures and crashes may happen due to the game engine not being able to handle the increased memory usage.

Different types of DXT compression

The different numbers of DXT are settings for alpha maps (transparency). DXT1 (BC1) supports an alpha channel that is either fully transparent or fully opaque, but it is typically used for completely opaque textures, for example all specular and normal maps. DXT3 (BC2) has an alpha map, but it does not allow smooth transitions. DXT5 (BC3) supports an interpolated alpha and can be used for smooth transitions.


Avoiding greyscale discoloration with DXT compression

Often when converting to DDS, choosing any of the DXT formats will cause the discoloration due to the compression of the texture and leave you with a purple or green shade hanging over your texture. This table ranging from RGB 0, 0, 0 to RGB 255, 255, 255 can be used to see exactly what colors would be altered after export to DDS.


As an example, colors such as RGB 31, 31, 31 would result in being RGB 30, 31, 30. The green being a mere one above red and blue results in this green shade. Other examples are the inverse of that, such as RGB 40, 40, 40 which results in RGB 41, 40, 41 after compression. Because the green is lower in this case, the color takes on the purple shade.

Greyscale Compression Table

Compression algorithms differ for different tools. This comparison was created for the Nvidia Texture Tools Exporter.

The colors that resulted in grayscale RGB colors without any green or purple dominance in the DDS file are marked on the table with green ticks.




Sometimes, the compressed color is slightly different, an example of this is RGB 2, 2, 2 which results in RGB 3, 3, 3. Regardless of the rounding, its still equal and can be used but the key is to use the value before compression which was originally RGB 2, 2, 2, as marked in the table.


Color Swatches for Photoshop

Authors

Don’t have an account yet? Register yourself now and be a part of our community!