基于OpenGL ES的壓縮紋理有常見的如下幾種實現:
1. ETC1(Ericcson texture compression)
2. PVRTC(PowerVR texture compression)
3. ATITC(ATI texture compression)
對于使用NVIDIA Tegra2芯片的手機如Motorola XOOM,ATRIX和DRIOID BIONIC則支持如下的紋理壓縮
4. S3TC(S3 texture compression)
ETC1:
ETC1格式是OpenGL ES圖形標準的一部分,并且被所有的Android設備所支持。擴展名為: GL_OES_compressed_ETC1_RGB8_texture,不自持透明通道,所以僅能用于不透明紋理。
PVRTC:
被用在Motorola的一些機器上,比如DROID系列。GPU為Imagination Technologies的PowerVR SGX 530。OpenGL ES的擴展名為: GL_IMG_texture_compression_pvrtc,支持預處理壓縮。當加載壓縮紋理時,<internal format>參數支持如下幾種格式:
COMPRESSED_RGB_PVRTC_4BPPV1_IMG (RGB 4 bit per pixel)
COMPRESSED_RGB_PVRTC_2BPPV1_IMG (RGB 2 bit per pixel)
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG (RGB 4 bit per pixel with alpha channel)
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG (RGB 2 bit per pixel with alpha channel)
ATITC:
當前使用該種紋理壓縮的機器有Nexus One。支持的OpenGL ES擴展名為: GL_ATI_texture_compression_atitc。當加載壓縮紋理時,<internal format>參數支持如下類型的紋理:
ATC_RGB_AMD (RGB textures)
ATC_RGBA_EXPLICIT_ALPHA_AMD (RGB textures using explicit alpha encoding)
ATC_RGBA_INTERPOLATED_ALPHA_AMD (RGBA textures using interpolated alpha encoding)
S3TC
也被稱為DXTC,在PC上廣泛被使用,但是在移動設備上還是屬于新鮮事物。在使用NVIDA芯片的手機上被使用。OpenGL ES擴展名為: GL_EXT_texture_compression_dxt1和GL_EXT_texture_compression_s3tc。當加載壓縮紋理時,<internal format>的參數有如下幾種格式:
GL_COMPRESSED_RGB_S3TC_DXT1 (RGB data is compressed, alpha is always 1.0)
GL_COMPRESSED_RGBA_S3TC_DXT1 (RGB data is compressed, alpha is either 1.0 or 0.0)
GL_COMPRESSED_RGBA_S3TC_DXT3 (RGB data is compressed, alpha is stored as 4 bits)
GL_COMPRESSED_RGBA_S3TC_DXT5 (RGB data is compressed, alpha is a weighted average of 8-bit values)
在程序在開始檢測這些可用的擴展很重要。對于ETC1壓縮來說,使用ETC1Util.isETC1Supported()即可。可以使用android.openGL.getString(GL10.GL_EXTENSIONS)解析字符串獲取更多的可用擴展。
參考:http://developer.motorola.com/docstools/library/understanding-texture-compression/