S3 Texture Compression
Encyclopedia
S3 Texture Compression (sometimes also called DXTn or DXTC) is a group of related lossy texture compression
Texture compression
Texture compression is a specialized form of image compression designed for storing texture maps in 3D computer graphics rendering systems. Unlike conventional image compression algorithms, texture compression algorithms are optimized for random access....

 algorithm
Algorithm
In mathematics and computer science, an algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. Algorithms are used for calculation, data processing, and automated reasoning...

s originally developed by Iourcha et al. of S3 Graphics, Ltd.
S3 Graphics
S3 Graphics, Ltd is an American company specializing in graphics chipsets. Although they do not have the large market share that they once had, they still produce graphics accelerators for home computers under the "S3 Chrome" brand name.-History:...

  for use in their Savage 3D computer graphics accelerator. The method of compression is strikingly similar to the previously published Color Cell Compression
Color Cell Compression
Color Cell Compression is an early lossy image compression algorithm first described by Campbell et. al. in 1986. It is a variant of Block Truncation Coding. The encoding process works on small blocks of pixels...

, which is in turn an adaptation of Block Truncation Coding
Block Truncation Coding
Block Truncation Coding, or BTC, is a type of lossy image compression technique for greyscale images. It divides the original images into blocks and then uses a quantiser to reduce the number of grey levels in each block whilst maintaining the same mean and standard deviation...

 published in the late 1970s. Unlike some image compression algorithms (e.g. JPEG
JPEG
In computing, JPEG . The degree of compression can be adjusted, allowing a selectable tradeoff between storage size and image quality. JPEG typically achieves 10:1 compression with little perceptible loss in image quality....

), S3TC's fixed-rate data compression coupled with the single memory access (cf. Color Cell Compression and some VQ
Vector quantization
Vector quantization is a classical quantization technique from signal processing which allows the modeling of probability density functions by the distribution of prototype vectors. It was originally used for data compression. It works by dividing a large set of points into groups having...

-based schemes) made it well-suited for use in compressing textures
Texture mapping
Texture mapping is a method for adding detail, surface texture , or color to a computer-generated graphic or 3D model. Its application to 3D graphics was pioneered by Dr Edwin Catmull in his Ph.D. thesis of 1974.-Texture mapping:...

 in hardware-accelerated 3D computer graphics
3D computer graphics
3D computer graphics are graphics that use a three-dimensional representation of geometric data that is stored in the computer for the purposes of performing calculations and rendering 2D images...

. Its subsequent inclusion in Microsoft
Microsoft
Microsoft Corporation is an American public multinational corporation headquartered in Redmond, Washington, USA that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions...

's DirectX
DirectX
Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...

 6.0 and OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 1.3 (via the GL_EXT_texture_compression_s3tc extension) led to widespread adoption of the technology among hardware and software makers. While S3 Graphics is no longer a competitor in the graphics accelerator market, license fees are still levied and collected for the use of S3TC technology, for example in game consoles and graphics cards. The patent-encumbered status of S3TC and its wide use in software, despite non-encumbered alternatives, have led to a de facto
De facto
De facto is a Latin expression that means "concerning fact." In law, it often means "in practice but not necessarily ordained by law" or "in practice or actuality, but not officially established." It is commonly used in contrast to de jure when referring to matters of law, governance, or...

 requirement for OpenGL drivers to support it and present a major obstacle to open source
Open source
The term open source describes practices in production and development that promote access to the end product's source materials. Some consider open source a philosophy, others consider it a pragmatic methodology...

 implementations.

In September of 2011, Intel employee Ian Romanick mentioned that the S3TC patent had been marked as invalid in patent litigation between Apple and HTC
HTC
-Companies:*HTC Corporation, a Taiwanese manufacturer of handheld devices*Harrisonville Telephone Company, a telephone company in Waterloo, Illinois*Horry Telephone Cooperative, a telephone cooperative in Horry County, South Carolina...

 , the latter of which acquired S3 and all of their patents. If the patent does prove to be invalid, it would be a simple matter of enabling support for it in Mesa 3D, a popular open source OpenGL-compatible computer graphics library. Currently, the only way Mesa 3D can work around the patent issue is to look for an external library capable of handling the S3TC formats (libtxc_dxtn.so), and loading it if found. There is another option, set through an environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

, that will cause Mesa 3D to expose the S3TC extension without actually supporting it. While this will not work for most applications that expect the functionality, there are some applications that check for the functionality and fail to start without it, but which do not actually or correctly use the functionality of S3TC. If that is the case, this alternative might make the application work anyway without S3TC support.

Codecs

There are five variations of the S3TC algorithm (named DXT1 through DXT5, referring to the FourCC
FourCC
A FourCC is a sequence of four bytes used to uniquely identify data formats.The concept originated in the OSType scheme used in the Macintosh system software and was adopted for the Amiga/Electronic Arts Interchange File Format and derivatives...

 code assigned by Microsoft to each format), each designed for specific types of image data. All convert a 4×4 block of pixels to a 64-bit
Bit
A bit is the basic unit of information in computing and telecommunications; it is the amount of information stored by a digital device or other physical system that exists in one of two possible distinct states...

 or 128-bit quantity, resulting in compression ratios of 6:1 with 24-bit RGB
RGB color space
An RGB color space is any additive color space based on the RGB color model. A particular RGB color space is defined by the three chromaticities of the red, green, and blue additive primaries, and can produce any chromaticity that is the triangle defined by those primary colors...

 input data or 4:1 with 32-bit RGBA
RGBA color space
RGBA stands for Red Green Blue Alpha. While it is sometimes described as a color space, it is actually simply a use of the RGB color model, with extra information. The color is RGB, and may belong to any RGB color space, but an integral alpha value as invented by Catmull and Smith between 1971 and...

 input data. S3TC is a lossy
Lossy data compression
In information technology, "lossy" compression is a data encoding method that compresses data by discarding some of it. The procedure aims to minimize the amount of data that need to be held, handled, and/or transmitted by a computer...

 compression algorithm, resulting in image quality degradation, an effect which is minimized by the ability to increase texture resolutions while maintaining the same memory requirements. Hand-drawn cartoon-like images do not compress well, nor do normal map data, both of which usually generate artifacts. ATI
ATI Technologies
ATI Technologies Inc. was a semiconductor technology corporation based in Markham, Ontario, Canada, that specialized in the development of graphics processing units and chipsets. Founded in 1985 as Array Technologies Inc., the company was listed publicly in 1993 and was acquired by Advanced Micro...

's 3Dc
3Dc
3Dc , also known as DXN, BC5, or Block Compression 5 is a lossy data compression algorithm for normal maps invented and first implemented by ATI. It builds upon the earlier DXT5 algorithm and is an open standard...

 compression algorithm is a modification of DXT5 designed to overcome S3TC's shortcomings with regard to normal maps. id Software
Id Software
Id Software is an American video game development company with its headquarters in Richardson, Texas. The company was founded in 1991 by four members of the computer company Softdisk: programmers John Carmack and John Romero, game designer Tom Hall, and artist Adrian Carmack...

 worked around the normalmap compression issues in Doom 3
Doom 3
Doom 3 is a science fiction horror video game developed by id Software and published by Activision. An example of the first-person shooter genre, Doom 3 was first released for Microsoft Windows on August 3, 2004. The game was later adapted for Linux, as well as being ported by Aspyr Media for Mac...

 by moving the red component into the alpha channel before compression and moving it back during rendering in the pixel shader.

Like many modern image compression algorithms, S3TC only specifies the method used to decompress images, allowing implementers to design the compression algorithm to suit their specific needs, although the patent still covers compression algorithms. The nVidia GeForce 1 through to GeForce 4 cards also used 16-bit interpolation to render DXT1 textures, which resulted in banding when unpacking textures with color gradients. Again, this created an unfavorable impression of texture compression, not related to the fundamentals of the codec itself.

DXT1

DXT1 (also known as Block Compression 1 or BC1) is the smallest variation of S3TC, storing 16 input pixels in 64 bits of output, consisting of two 16-bit RGB 5:6:5 color values and a 4x4 two bit lookup table.

If the first color value () is numerically greater than the second color value (), then two other colors are calculated, such that and .
This mode operates similarly to mode 0xC0 of the original Apple Video codec.

Otherwise, if , then and is transparent black corresponding to a premultiplied alpha format
Alpha compositing
In computer graphics, alpha compositing is the process of combining an image with a background to create the appearance of partial or full transparency. It is often useful to render image elements in separate passes, and then combine the resulting multiple 2D images into a single, final image in a...

.

The lookup table is then consulted to determine the color value for each pixel, with a value of 0 corresponding to and a value of 3 corresponding to . DXT1 does not store alpha data enabling higher compression ratios.


DXT2 and DXT3

DXT2 and DXT3 (collectively also known as Block Compression 2 or BC2) converts 16 input pixels (corresponding to a 4x4 pixel block) into 128 bits of output, consisting of 64 bits of alpha channel data (4 bits for each pixel) followed by 64 bits of color data, encoded the same way as DXT1 (with the exception that the 4 color version of the DXT1 algorithm is always used instead of deciding which version to use based on the relative values of and ).
In DXT2, the color data is interpreted as being premultiplied by alpha, in DXT3 it is interpreted as not having been premultiplied by alpha. Typically DXT2/3 are well suited to images with sharp alpha transitions, between translucent and opaque areas.


DXT4 and DXT5

DXT4 and DXT5 (collectively also known as Block Compression 3 or BC3) converts 16 input pixels into 128 bits of output, consisting of 64 bits of alpha channel data (two 8 bit alpha values and a 4x4 3 bit lookup table) followed by 64 bits of color data (encoded the same way as DXT2 and DXT3).

If , then six other alpha values are calculated, such that , , , , , and .

Otherwise, if , four other alpha values are calculated such that , , , and with and .

The lookup table is then consulted to determine the alpha value for each pixel, with a value of 0 corresponding to and a value of 7 corresponding to . DXT4's color data is premultiplied by alpha, whereas DXT5's is not. Because DXT4/5 use an interpolated alpha scheme, they generally produce superior results for alpha (transparency) gradients than DXT2/3.


S3TC Format Comparison

FOURCC DX 10 Name Description Alpha premultiplied? Compression ratio Texture Type
DXT1 BC1 1-bit Alpha / Opaque N/A 6:1(for 24 bit source image) Simple non-alpha
DXT2 (none) Explicit alpha Yes 4:1 Sharp alpha
DXT3 BC2 Explicit alpha No 4:1 Sharp alpha
DXT4 (none) Interpolated alpha Yes 4:1 Gradient alpha
DXT5 BC3 Interpolated alpha No 4:1 Gradient alpha

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK