Shader X4 - Image Space - Texture Compression with Coefficient Domain Shaders



S3TC compresses at 6:1 ratio. We can get much higher texture compression (16:1 for instance) with comparable quality if we can spare some GPU cycles. The method used in this method is DCT, Discrete Cosine Transform.

The basic idea is, we divide the source image into blocks (like S3TC), convert these blocks from spatial space to frequency, producing coefficients the same dimensions as the blocks. We throw away the highest frequency coefficients, achieving compression. Then we quantize them for textures. Store them in textures.

We generate a cosine lookup table and pop that onto the GPU constants.

Decoding a compressed texture is a sum of texture reads, processing each one thru a cosine table lookup.