ASTC Texture Compression
|ARB extension||KHR_texture_compression_astc_hdr, KHR_texture_compression_astc_ldr|
Adaptable Scalable Texture Compression (ASTC) is a form of Texture Compression that uses variable block sizes, rather than a single fixed size. ASTC is designed to effectively obsolete all (or at least most) prior compressed formats by providing all of the features of the others plus more, all in one format.
- S3 Texture Compression
- ASTC has better peak signal-to-noise than DXT3/5 at the same block size. But because of ASTC's variable block size, ASTC can also beat DXT1's 4-bits-per-pixel, going as far down as 0.89bpp. At similar bitdepths, ASTC provides better visual quality than DXT1.
- BPTC Texture Compression
- BPTC provides two features: improved image quality for normalized integer formats and floating-point compression. The HDR profile of ASTC covers the latter, and ASTC's compression for the same bitrate is approximately equivalent to BPTC's normalized formats. ASTC also handles
- Red Green Texture Compression
- ASTC provides a single-channel and two-channel version, equivalent to RGTC's formats. What is important with RGTC, and the reason to use it rather than regular S3TC, is that the two channels are uncorrelated with one another. The gradient used for one channel has no relation to the gradient used for the other. So two axes that don't visually correlate will compress better for the same bpp.
- ASTC provides both correlated and uncorrelated two-channel compression.
- One feature of RGTC missing from ASTC (directly at least) is support for signed, normalized integer values. This can be approximated however by biasing the data (pre-compression) by 127 (assuming that you properly removed all -128 values from your data), to make it unsigned. Then, in the shader, multiplying the result sampled from the texture by 2 and subtracting 1 to reconstitute the signed value.
Of course, the downside is that ASTC is not widely available at present. It is available as an OpenGL extension, but it is not core OpenGL functionality.
Also, note that the ASTC extension is written against OpenGL ES 3.0, not desktop OpenGL. This means that some of its functionality is limited, relative to desktop GL.
|This article is a stub. You can help the OpenGL Wiki by expanding it.|
Variable block sizes
Compression formats used for textures are based on compressing specific blocks of pixels. This makes it easy for hardware to tell what has to be decompressed to get at a specific texel, which is a frequent operation in texture accessing.
Most compression formats have a fixed size of blocks. S3TC, BPTC, and RGTC all use 4x4 pixel blocks. The byte sizes can be different based on different variations of the format. DXT1 in S3TC uses 8-byte blocks, while DXT3/5 use 16-byte blocks.
ASTC is a bit different. The algorithm is designed to be able to work against a large range of block sizes in terms of pixel footprints. However, the amount of space a block takes up is always 16-bytes. Therefore, the number of bits per pixel that ASTC takes up is determined by the block size used. So the 4x4 version of ASTC, the smallest block size, takes up 8 bits per pixel, while the 12x12 version takes up only 0.89bpp.
The range of blocks ASTC offers (for 2D compression) is to the left.
Most compressed formats offer a fairly limited array of color channel support. BPTC's normalized integer support provides 4 channels, always. The various RGTC formats only allow for 2 channels. And so forth.
ASTC is much more flexible. It supports from 1 to 4 channels, and it allows the user to control whether certain channels are correlated or not. What is meant by "correlated" is that the two channels will be tied to the same gradient. Correlating channels makes the data smaller, but it also means that there can be a degree of bias, where a particular gradient in a block provides more accuracy to one channel than another.
Correlating channels is often useful for color data (or at least, it's usually not too bad). However, for data like normals, it may well result in rather ugly results.
ASTC provides the following color channel possibilities:
- Single channel (analogous to Red-only RGTC).
- Two channels, correlated.
- Two channels, uncorrelated (analogous to Red/Green RGTC).
- Three channels, all correlated (analogous to DXT1).
- Three channels, with the third uncorrelated from the first two.
- Four channels, all correlated.
- Four channels, with the fourth uncorrelated from the first three (analogous to DXT3/5).
While these are important elements of an ASTC compressed image, the specific details of correlation are selected on a per-block basis. So even if you request two correlated channels the compressor may decide that, for certain blocks, the uncorrelated version will result in a better output. Or even for all of them.
ASTC can compress floating-point data as well as integer data. Like BPTC, it is restricted to only non-negative floating-point values.
OpenGL image formats
ASTC works with all OpenGL texture types. For 2D and 2D array textures,
The ASTC format defines additional functionality which has not yet been exposed to OpenGL. Specifically, it has the concept of volumetric compression, where the blocks are 3-dimensional blocks rather than two-dimensional blocks.