In relation to computer graphics, texture compression is a way to take an image that will be used as a texture on an object, usually in a three-dimensional (3D) scene, and reduce the amount of memory the image requires. Unlike more traditional image compression algorithms, texture compression methods attempt to provide a way to keep the compressed image in memory while also allowing a program to access specific pixels within the image without having to completely decompress the image. There are several ways this is achieved, including block truncation coding (BTC), although the savings in memory space during program execution usually must be balanced against an increase in processor usage or a reduction in image quality resulting from the use of lossy compression. Most frequently, the manufacturers of different graphics cards and other devices implement support for texture compression directly into the hardware, leading to several common compression algorithms bearing the names of different hardware manufacturers.
One reason why texture compression was developed and has become a common technique in 3D graphics is that it can take several dozen gigabytes of memory to store uncompressed image textures for scenes intended to be viewed on higher-resolution monitors. Additionally, handheld digital devices generally have limited amounts of memory that otherwise would be unable to hold the required images for a 3D scene. Texture compression reduces the amount of memory needed on a system so more textures, or higher-quality textures, can be used.
The most basic type of texture compression is known as block truncation coding. This method takes an image and divides it into small blocks of pixels, finding the two colors within the block that are the farthest apart from a color space perspective. The actual image pixels within the block are then assigned a numerical value to indicate their color in relation to the two extreme colors. The scheme compresses an image because the amount of bits required to store a pixel’s deviation from the colors in a block are less than what is required to store the actual color. The resulting compression also provides a way to index pixels directly from the compressed image as needed.
Depending on the hardware, software and other factors, texture compression can occur at runtime or can be performed beforehand and saved as a file. Dynamically created textures always must be compressed during execution. Loading a compressed texture from a file can be faster initially, but it also can cause problems if the hardware does not support a specific type of compression.