A high-performance command-line tool for compressing image files into DirectX texture formats using block compression.
DDS Texture Compressor converts common image formats (PNG, JPG, TGA, BMP, etc.) into optimized DDS textures using a variety of compression algorithms. It supports modern GPU-friendly formats including BC4, BC5, BC6H, and BC7, as well as legacy formats like DXT1 and DXT5.
-
Multiple compression formats:
- DXT1/BC1: RGB compression (no alpha), 8:1 compression ratio
- DXT5/BC3: RGBA compression with alpha, 4:1 compression ratio
- BC4: Single-channel compression (for masks, height maps)
- BC5: Two-channel compression (normal maps, RG-only textures)
- BC6H: High-quality HDR image compression
- BC7: High-quality RGBA compression with minimal artifacts
-
Image preprocessing:
- Automatic adjustment to dimensions divisible by 4
- Automatic channel conversion to match format requirements
- Support for various input formats (PNG, JPG, TGA, BMP, etc.)
- HDR support with automatic format selection
-
Optimization:
- Fast compression using ISPC (Intel SPMD Program Compiler) texcomp
- Automatic HDR detection with BC6H format selection
- C++17 compatible compiler
- CMake 3.10 or higher (for building)
- Dependencies:
- ISPC Texture Compression library
- STB Image library (included)
# Clone the repository
git clone https://github.com/yourusername/dds-texture-compressor.git
cd dds-texture-compressor
# Create build directory
mkdir build
cd build
# Configure and build
cmake ..
make
ddscompressor <input_file> <output_file> [format]
input_file
: Path to the source image (PNG, JPG, TGA, BMP, HDR, etc.)output_file
: Path for the output DDS fileformat
: (Optional) Compression format to use:dxt1
: Legacy RGB compression (no alpha)dxt5
: Legacy RGBA compression (with alpha)bc4
: Single channel compression (red only)bc5
: Two channel compression (red & green)bc6h
: HDR compressionbc7
: High-quality RGBA compression (default)
# Basic usage with default BC7 compression
ddscompressor input.png output.dds
# Compress a normal map with BC5
ddscompressor normal_map.png normal_map.dds bc5
# Compress an HDR image (automatically uses BC6H)
ddscompressor envmap.hdr envmap.dds
# Compress a UI texture with alpha using DXT5
ddscompressor ui_element.png ui_element.dds dxt5
- BC7 (default): Best for general-purpose RGBA textures with high quality requirements.
- BC6H: Designed specifically for HDR images.
- BC5: Ideal for normal maps (RG channels - blue can be reconstructed).
- BC4: Use for single-channel data like height maps or masks.
- DXT5: Legacy format for RGBA textures, use when targeting older hardware.
- DXT1: Legacy format for RGB textures without alpha, smallest file size.
The DDS (DirectDraw Surface) file format is designed for storing textures and is closely associated with Microsoft DirectX. It supports various forms of texture compression, mipmaps, and other advanced features.
All supported formats use block compression, where each 4×4 block of pixels is compressed into a fixed amount of bytes:
- DXT1/BC1: 8 bytes per block (0.5 bytes per pixel)
- DXT5/BC3, BC4, BC5, BC6H, BC7: 16 bytes per block (1 byte per pixel)
- The program uses the Intel ISPC Texture Compression library for high-performance compression.
- All image dimensions are rounded up to multiples of 4 to comply with block compression requirements.
- For HDR images, the program automatically switches to BC6H format regardless of the specified format.
- STB Image for image loading.
- ISPC Texture Compression for the compression algorithms.