Common texture and texture compression formats

Source: Internet
Author: User

Reprint to: http://blog.csdn.net/ynnmnm/article/details/44983545 by Night Wind

Simple Texture format
    • RGBA8888 4 bytes per pixel, 8-bit for RGBA channels
    • RGBA4444 2 bytes per pixel, 4-bit for RGBA channels
    • RGB888 3 bytes per pixel, 8-bit RGB channels, no transparent channels
    • RGB565 per pixel 2 bytes, RGB channels occupy 5/6/5 bit, no transparent channel
    • RGBA5551 each pixel 2 bytes, RGB channel each occupies 5 bits, transparent channel 1 bits, so either completely transparent or opaque
DXT Texture compression format

The DXT texture compression format is derived from the S3TC (S3 Texture Compression) proposed by S3 (Silicon & Software Systems), where the basic idea is to compress a 4x4 pixel block into a 64-or 128-bit block of data, is a lossy compression method. DXT1-DXT5 is the five variations of the S3TC algorithm for a variety of Windows devices.

DXT1

The DXT1 format is primarily suitable for non-transparent maps or maps with only one alpha (not fully transparent or completely opaque), DXT1 has a compression ratio of 4:1, which means 4 bits per pixel color, even though the compression ratio is not very good, for maps of a fully RGB565 format. But Dxt's features make it more suitable for real-time gaming.

DXT1 treats each 4x4 block as a single compression unit, the compressed 4x4 block occupies 64 bits, which has 2 16-bit RGB colors and 16 2-bit indexes, and the format is depicted as follows:

The two RGB colors in DXT1 are responsible for representing the two extreme values of the color in the compressed 4x4 pixel block, and then we can calculate the two median color values by linear interpolation, while 16 2-bit indexes indicate the color value of the pixel in which the 4x4 pixel blocks are located, 2 bits can represent 4 states, Just to fully represent color_0,color_1 and the median color values color_2 and color_3 that we calculated by interpolation, and for a map with one alpha, only one median color value is computed, and color_3 is used to represent full transparency.

For how to determine if the DXT1 format is a map that represents opacity or 1-bit alpha, it is implemented by two color values color_0 and color_1, and if the COLOR_0 value is greater than color_1, the map is completely opaque, whereas the other is a transparent message. Because there is only one Alpha message, it can only be transparent or opaque, so DXT1 transparency is actually a hollow, using the transparent effect of the mesh, we generally do not need the picture quality requirements and transparent information to use this format.

Dxt2/dxt3

DXT2 and DXT3 can represent maps with more complex transparency information, both of which take the form of an explicit alpha representation, and we know that in DXT1 we use 64-bit data to describe the color information of a 4*4 pixel block, in DXT2 and DXT3, this part of the color information is constant, Instead, by appending 64 bits of data, which is 4 bits per pixel, to represent their alpha transparency information, the 4-bit alpha information is typically represented by direct encoding.

In this way, each 4x4 pixel block occupies 128 bits, or 8 characters, and the 0~3 word represents transparent information; 4~7 represents the color information described earlier.

The difference between DXT2 and DXT3 is that the color in DXT2 is already done with the premultiplied by Alpha operation (a blend of the finished color and alpha, which changes the overall color value directly when the transparency changes, eliminating the need to compound separately). DXT3 's alpha information is relatively independent, and the reason to differentiate is to adapt to different needs, because some occasions require independent alpha information.

DXT2/DXT3 is mainly used for the sharp alpha channel, strong contrast material, such as hollow or partially semi-permeable material.

Dxt4/dxt5

DXT4, DXT5 is also used to represent maps with complex transparency information, unlike 2 and 3, where alpha information of 4 and 5 is computed by linear interpolation, similar to the color information of DXT1. Similarly, the transparent information for each 4x4 pixel block occupies 64 bits, the difference being that 64 bits have 2 8-bit alpha values and 16 3-bit index values, and since each pixel has an index of 3 bits, it can represent 8 different transparent states.

There are two ways to interpolate here, one to represent a state with full transparency and full opacity, and the other to interpolate only in the given extreme values alpha_0 and alpha_1. The differentiated method is also achieved by comparing the size of the alpha_0 and alpha_1, and if the ALPHA_0 is greater than alpha_1, the remaining 6 intermediate alpha values are computed by interpolation, otherwise, only 4 intermediate alpha values are computed by interpolation, Alpha_6 directly assigns 0, The alpha_7 is directly assigned a value of 255.

The difference between DXT4 and DXT5 is the same as DXT2 and DXT3, and the DXT4 color value is understood as having completed the premultiplied by Alpha operation.

FOURCC Description Alpha premultiplied? Compression ratio Texture Type
DXT1 1-bit Alpha/opaque N/A 6:1 (for 24-bit source map) Simple Non-alpha
DXT2 Explicit Alpha Yes 4:1 Sharp Alpha
DXT3 Explicit Alpha No 4:1 Sharp Alpha
DXT4 Interpolated Alpha Yes 4:1 Gradient Alpha
DXT5 Interpolated Alpha No 4:1 Gradient Alpha
ETC Texture Compression format

Ericsson Texture Compression, an open standard supported by Khronos, is widely used in mobile platforms. It is a lossy algorithm designed for perceived quality, which is based on the human eye's response to changes in brightness above the chroma change. Similarly, DXT,ETC also compresses a 4x4 block of pixels into a 64-or 128-bit block of data, which is also lossy compression.

ETC1

ETC1 presses a 4x4 pixel unit into a 64-bit block of data. 4x4 pixel groups are first divided horizontally or vertically into 2 4x2 groups, each half having 1 base colors (rgb444/rgb444 or rgb555/rgb333 format), a 4-bit luminance index, and 8 2-bit pixel indexes. The color of each pixel equals the base color plus the luminance range that the index points to.

For example, for a one-and-a-half group:
1. The base color of 12 bits is RGB (0, 34, 255);
2.4-bit brightness index Select the brightness supplement from the brightness table, the brightness table has 16, the following table is 0-7,8-15 is 0-7 twice times.

Luminance Index 1 corresponds to (-12,-4, 4, 12);
3. The 2-bit pixel index is 0, so the luminance supplement is-12. The color value of this pixel can be obtained (0-12, 34-12, 255-12), i.e. (0, 22, 243).

The four mobile device GPUs support ETC1, so non-transparent textures on various Android devices can be in the ETC1 format, unfortunately ETC1 does not support transparency. For transparent textures, on Android devices, you can split RGB and alpha onto 2 ETC1 textures, which are then synthesized in the game.

ETC2

The ETC2 is a ETC1 extension, backwards compatible with ETC1, better compression of RGB, and supports transparent channels. The following ETC2 compression formats are currently supported on OpenGL ES 3.0 and OpenGL 4.3:
-GL_COMPRESSED_RGB8_ETC2 Compressed RGB888 format, similar to ETC1
-GL_COMPRESSED_RGBA8_ETC2_EAC Compressed RGBA8888 format to support full transparent channels
-GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 compressed RGBA data with only one alpha

The ETC2 is more compact than ETC1 and supports transparency, and no longer requires a different texture format for Android devices. However, OpenGL ES 3.0 or more is required, and many devices only support OpenGL ES 2.0.

PVRTC Texture compression format

The PowerVR Texture COMPRESSION,PVRTC format differs from the block-based compression format, such as S3TC, etc, which uses 2 of the low-resolution graphs of bilinear amplification, which are fused together to render textures based on precision and weight per pixel. And both 2-BPP and 4-BPP support ARGB data. PVRTC format compression ratio, also lossy compression.

PVRTC 2-BPP

2 bits per pixel, 2 bits per pixel, with poor quality, presses a 8x4 pixel unit group into a 64-bit block of data. 6 variables are stored in each block: modulated data (32-bit), Punch-through Alpha flag (1-bit), color a (15-bit), color a opaque flag (1-bit), Color B (14-bit), and color B's opaque flag (1-bit).

PVRTC 4-BPP

4 bits per pixel, 4 bits per pixel, presses a 4x4 pixel cell group into a 64-bit block of data. 6 variables are stored in each block: Modulation data (32-bit), modulation flag (1-bit), Color B (14-bit), hard-conversion flag (1-bit), color a (15-bit), and opaque flag (1-bit).

Note: Colors A and B must be in the same format (RGB or RGBA), and the entire texture is in this RGB or RGBA format. For more details on PVRTC please refer to [7] and a PVRTC2 format diagram is given below:

The PVRTC format can be used on all iOS devices and on Android devices that use the PowerVR GPU, which requires that the height and width of the texture must be a full power of 2, a minimum of 8, and must be a square.

Reference:
      1. Http://en.wikipedia.org/wiki/S3_Texture_Compression
      2. Http://en.wikipedia.org/wiki/Ericsson_Texture_Compression
      3. Http://en.wikipedia.org/wiki/PVRTC
      4. Http://www.jacobstrom.com/publications/StromAkenineGH05.pdf
      5. Http://www.jacobstrom.com/publications/packman_sketch.pdf
      6. http://malideveloper.arm.com/cn/develop-for-mali/sample-code/etcv1-texture-compression-and-alpha-channels/
      7. Http://web.onetel.net.uk/~simonnihal/assorted3d/fenney03texcomp.pdf
      8. Http://blog.imgtec.com/powervr/pvrtc2-taking-texture-compression-to-a-new-dimension
      9. Http://www.cnblogs.com/lancidie/archive/2011/04/27/2031026.html
      10. http://blog.csdn.net/lhc717/article/details/6802951
      11. Http://wiki.c3.91.com/index.php?title= handheld Platform Texture format description

Common texture and texture compression formats

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.