📅 2006-Aug-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ compression, textures ⬩ 📚 Archive
One of the most popular texture compression algorithms used in OpenGL are the DXTn series which were introduced by S3 Graphics. Hence, they are known as S3TC. The working of this algorithm can be found in the Appendix of GL_EXT_texture_compression_s3tc.
There are 5 versions available ranging from DXT1 to DXT5. DXT1 is briefly explained below:
A 4x4 texel block (48 bytes if texel is RGB) is compressed into 2 16-bit color values (c0 and c1) and a 4x4 2-bit lookup block.
c2 and c3 are calculated from c0 and c1 as follows:
If c0 <= c1, c2 = (c0 + c1) / 2; c3 = not defined; else c2 = (2 * c0 + c1) / 3; c3 = (c0 + 2 * c1) / 3;
Decompression is extremely fast. It is just a lookup of 2-4 precomputed values.
Read the 2-bit value of each compressed pixel. If 00 then read RGB of c0, if 01 then read RGB of c1 and so on.
VTC (GL_NV_texture_compression_vtc) is also based on the above ideas, just extend the texel blocks in the z direction.