ASTC compression tools

Several different tools are available to help developers use the ASTC format to compress their texture images.

These tools include:

Arm ASTC Encoder

The Arm ASTC Encoder (astcenc) is an open-source command-line tool for compressing and decompressing ASTC textures. The latest version, at the time of writing, is version 2.0.

Arm ASTC Encoder supports compression of the following formats into ASTC format output images:

  • Low Dynamic Range image formats: BMP, JPEG, PNG, and TGA
  • High Dynamic Range image formats: EXR and HDR
  • DDS and KTX container formats, though only a subset of format features is supported.

Compressed outputs can be written into a KTX container, or a simple .astc wrapper.

The astcenc application provides a full list of available command-line arguments. Use the -help option, shown in the following code, to see extensive help information, including usage instructions and details of all available command-line options:

astcenc -help 

Compression

Compress an image using the -cl, -cs, -ch, and -cH modes. For example, the following command compresses example.png using the LDR color profile and a 6x6 block footprint (3.55 bits/pixel):

astcenc -cl example.png example.astc 6x6 -medium

The -medium quality preset gives a reasonable image quality for a relatively fast compression speed. The output is stored to a linear color space compressed image example.astc.

The available modes are:

  • -cl use the linear LDR color profile
  • -cs use the sRGB LDR color profile
  • -ch use the HDR color profile, tuned for HDR RGB and LDR A
  • -cH use the HDR color profile, tuned for HDR RGBA

The available search presets are, in order of increasing quality and reducing compression speed:

  • -fast
  • -medium
  • -thorough
  • -exhaustive

The higher quality searches give diminishing quality improvements and increasingly long compression times. For most uses we would recommend starting with -medium and only moving to -thorough for images with insufficient quality.

There are many power-user options to control the compressor heuristics. Run astcenc --help for more details.

Decompression

Decompress an image using the -dl, -ds, -dh, and -dH modes. For example, the following command decompresses example.astc using the full HDR feature profile, storing the decompressed output to example.tga:

astcenc -dh example.astc example.tga

The available modes are:

  • -dl use the linear LDR color profile
  • -ds use the sRGB LDR color profile
  • -dh and -dH use the HDR color profile

Measuring image quality

Review the compression quality using the -tl, -ts, -th, and -tH modes. For example:

astcenc -tl example.png example.tga 5x5 -thorough

This command is equivalent to using the LDR color profile and a 5x5 block size to compress example.png, using the -thorough quality preset, and then immediately decompressing the image and saving the result to example.tga.

This process can be used to enable a visual inspection of the compressed image quality. In addition, this mode also prints out some image quality metrics to the console.

The available modes are:

  • -tl use the linear LDR color profile
  • -ts use the sRGB LDR color profile
  • -th use the HDR color profile, tuned for HDR RGB and LDR A
  • -tH use the HDR color profile, tuned for HDR RGBA

Compressing normal maps

The astcenc compressor has a special compression mode for normal maps, as their compression goals are quite different to color data. The normal map mode is enabled by specifying the -normal command line option. This has two effects:

  • The normal data is assumed to be unit length and packed into four channels as "x x x y". This allows the compressor to store only two values per endpoint, which frees up a significant amount of bitrate which can be used elsewhere.
  • The compressor optimizes for the angular error of the normal vector instead of absolute color channel error, which improves quality of the normal data even if data looks a little worse when viewed as a color image.

The -perceptual option can also be specified, which changes the compressor to optimize for perceptual quality rather than direct PSNR. The main objective of this for normal maps is to reduce the variability in the introduced errors, smoothing out the direction changes which can be badly amplified by specular lighting computations.

As these normal maps only store two components, the Z component of the normal must be reconstructed in shader code based on the knowledge that the vector is unit length. The GLSL code for reconstruction of the Z value is:

vec3 normal;
normal.xy = texture(...).ga;
normal.z = sqrt(1 - dot(normal.xy, normal.xy));

The following image shows the difference between compressing for three channel color (left), -normal (middle), and -normal -perceptual (right):

Compressing mask maps

The -mask option specifies that the input texture has entirely unrelated content in each channel. This option tells astcenc that it is undesirable for errors in one channel to affect other channels.

The following image shows an example of a bitmap font:

The red channel represents the characters, the blue channel is a rear glow, and the green channel is a drop shadow.

The left image is the uncompressed data. The middle image is compressed with default settings, and the right image uses the -mask argument.

Compressing 3D textures

To compress a volumetric 3D texture, specify the -array <size> option, where >size< is the Z dimension of the texture.

When the -array argument is specified, the input filename is interpreted as a prefix. The actual input files are named with the specified prefix plus _0, _1, and so on, up to <size>-1.

For example, the following command loads files named slice_0.png, slice_1.png, slice_2.png, and slice_3.png:

astcenc -c slice.png slice.astc 4x4x4 -array 4 -medium

Arm Mali Texture Compression Tool

Arm Mali Texture Compression Tool is a GUI application for exploring texture compression and visualizing the results, supporting ASTC, ETC, and ETC2. It is no longer under active development, and so does not support the latest astcenc command-line tool, but it is still a useful tool for experimentation and visualization. The following image shows the Arm Mali Texture Compression Tool:

The following image shows the Compression options dialog. This dialog lets you select a quality preset (Compression mode) and other settings depending on texture usage:

Intel ISPC Texture Compressor

The Intel ISPC Texture Compressor, is a compression library developed by Intel, supporting multiple texture formats include ASTC. It uses the Intel ISPC (Implicit SPMD Program Compiler) compiler to parallelize key parts of the compressor implementation for the target CPU SIMD instruction set.

The ASTC support in the tool only supports the 2D LDR profile and block sizes up to 8x8. It has image quality that is similar to astcenc -fast for photographic imagery, but can be up to three times faster at compressing. Its quality is measurably worse than astcenc -fast for non-photographic imagery, such as normal maps, mask maps, or cartoon-like color data.

AMD Compressonator

AMD Compressonator is a set of SDK, command-line, and GUI tools. Compressonator supports many texture compression formats and provides useful features like batch processing and texture preview.

Compressonator has limited support for ASTC, exposing little control over image quality or compression options. It has significantly slower compression times than the other tools in this section.

Previous Next