图片纹理压缩方案

Unity支持多种图像格式作为导入纹理的源文件(JPG,PNG,PSD,TGA),Unity会将它们转换成自己支持的Texture2D格式,在Texture2D的选项设置中,针对不同平台和实际需求,选择合适的压缩格式,尽量减少图片纹理的占用内存。

官方文档给出了所有支持的纹理压缩格式:官方文档链接,选择纹理压缩格式是图片内存大小与图片质量之间的权衡。同时,要选择平台支持的纹理压缩格式,当使用目标平台不支持的纹理压缩格式时,纹理将解压缩为RGBA 32,并与压缩的纹理一起存储在内存中。发生这种情况时,会浪费时间对纹理进行解压缩,并且浪费内存。此外,不同平台均具有不同的硬件,对特定的压缩格式进行了优化,选择不兼容的格式会影响游戏的性能。

Android平台下不带透明通道优先使用ETC1,带透明通道的优先使用ETC2,要求更高质量可使用RGBA16,RGBA32。IOS平台下优先使用PVRTC,其次是ASTC。要求更高质量可使用RGBA16,RGBA32。

图片占用的内存越小,加载速度越快,游戏性能越好。但一些的压缩格式对图片的尺寸有一些限制。ETC1,ETC2以及ASTC4x4要求图片的尺寸的宽和高可以不相等但必须被4整除;IOS的PVRTC压缩格式要求图片的宽高必须相等而且是2的整数次幂,否则无法压缩。另外ETC2和ASTC对硬件也有一些限制,ETC2只支持OpenGL ES 3.0以上的Android手机,ASTC只支持苹果A8以后的设备。这些都是在选择压缩格式要注意的事项。

下面的表格显示了每种压缩格式的支持平台。

Texture compression format Description Size
for a 256x256 pixel Texture
Platform Support
RGB Compressed DXT1 压缩无符号整型整型RGB纹理。 32KB (4 bits per pixel) Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra and Intel Bay Trail), WebGL

Note: With linear rendering on web browser that doesn’t support sRGB DXT, textures are uncompressed at run time to RGBA32.

RGB Crunched DXT1 类似于RGB压缩DXT1,但使用压缩压缩压缩。请参阅上面的注释,了解更多关于压缩压缩的内容。 Variable, depending on the complexity of the content in the texture. Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra and Intel Bay Trail), WebGL

Note: With linear rendering on a web browser that doesn’t support sRGB DXT, textures are uncompressed at run time to RGBA32.

RGBA Compressed DXT5 压缩无符号整型整型RGBA纹理。每像素8位。 64KB (8 bits per pixel) Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra and Intel Bay Trail), WebGL

Note: With linear rendering on a web browser that doesn’t support sRGB DXT, textures are uncompressed at run time to RGBA32.

RGBA Crunched DXT5 与RGBA压缩DXT5相似,但使用压缩压缩压缩。请参阅上面的注释,了解更多关于压缩压缩的内容。 Variable, depending on the complexity of the content in the texture. Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra and Intel Bay Trail), WebGL

Note: With linear rendering on a web browser that doesn’t support sRGB DXT, textures are uncompressed at run time to RGBA32.

RGB Compressed BC6H 压缩无符号浮动/高动态范围(HDR)RGB纹理。 64KB (8 bits per pixel) Windows Direct3D 11: OpenGL 4, Linux.

Note: BC6H Textures are uncompressed at run time to RGBA half on the following platform configurations:
- macOS with OpenGL
- Platforms with Direct3D 10 Shader Model 4 or OpenGL 3 GPUs.

RGB(A) Compressed BC7 高质量的压缩无符号整型整型RGB或RGBA纹理。 64KB (8 bits per pixel) Windows Direct3D 11: OpenGL 4, Linux

Note: BC7 Textures are uncompressed at run time to RGBA 32bits on the following platform configurations:
- macOS with OpenGL
- Platforms with Direct3D 10 Shader Model 4
Platforms with OpenGL 3 GPUs.

RGB Compressed ETC 压缩RGB纹理。这是一种默认的纹理压缩格式,没有Android项目的alpha通道。 32KB (4 bits per pixel) Android, iOS, tvOS.
Note: ETC1 is supported by all OpenGL ES 2.0 GPUs. It does not support alpha.
RGB Crunched ETC 类似于RGB压缩等,但使用压缩压缩压缩。请参阅上面的注释,了解更多关于压缩压缩的内容。 Variable, depending on the complexity of the content in the texture. Android, iOS, tvOS.
RGB Compressed ETC2

压缩RGB纹理。

32KB (4 bits per pixel) Android (OpenGL ES 3.0)
Note: On Android platforms that don’t support ETC2, the texture is uncompressed at run time to the format specified by ETC2 fallback in the Build Settings.
RGBA Compressed ETC2 压缩RGBA纹理。这是用于Android项目的alpha通道纹理的默认纹理压缩格式。 64KB (8 bits per pixel) Android (OpenGL ES 3.0), iOS (OpenGL ES 3.0), tvOS (OpenGL ES 3.0)

Note: On iOS and tvOS devices that don’t support ETC2, the texture is uncompressed at run time to RGBA32. On Android platforms that don’t support ETC2, the texture is uncompressed at run time to the format specified by ETC2 fallback in the Build Settings.

RGBA Crunched ETC2 类似于RGBA压缩ETC2,但是使用压缩压缩压缩。请参阅上面的注释,了解更多关于压缩压缩的内容。 Variable, depending on the complexity of the content in the texture. Android (OpenGL ES 3.0), iOS (OpenGL ES 3.0), tvOS (OpenGL ES 3.0)

Note: On iOS and tvOS devices that don’t support ETC2, the texture is uncompressed at run time to RGBA32. On Android platforms that don’t support ETC2, the texture is uncompressed at run time to the format specified by ETC2 fallback in the Build Settings.

RGB Compressed ASTC 可变块大小压缩RGB纹理。 12x12: 0.89 bits per pixel (7.56KB for a 256x256 Texture)
10x10: 1.28 bits per pixel (10.56KB for a 256x256 Textures)
8x8: 2 bits per pixel (16KB for a 256x256 Texture);
6x6: 3.56 bits per pixel (28.89KB for a 256x256 Texture)
5x5: 5.12 bits per pixel (42.25KB for a 256x256 Texture)
4x4: 8 bits per pixel (64KB for a 256x256 Texture)
tvOS (all), iOS (A8), Android (PowerVR 6XT, Mali T600 series, Adreno 400 series, Tegra K1).
RGBA Compressed ASTC 可变块大小压缩RGBA纹理。 12x12: 0.89 bits per pixel (7744 bytes for a 256x256 Texture)
10x10: 1.28 bits per pixel (10816 bytes for a 256x256 Textures)
8x8: 2 bits per pixel (16KB for a 256x256 Texture);
6x6: 3.56 bits per pixel (29584 bytes for a 256x256 Texture)
5x5: 5.12 bits per pixel (43264 bytes for a 256x256 Texture)
4x4: 8 bits per pixel (64KB for a 256x256 Texture)
tvOS (all), iOS (A8), Android (PowerVR 6XT, Mali T600 series, Adreno 400 series, Tegra K1).
RGB Compressed PVRTC 2 bits 高压缩RGB纹理。质量低,但尺寸小,性能更佳。 16KB (2 bits per pixel) Android (PowerVR), iOS, tvOS.
RGBA Compressed PVRTC 2 bits 高压缩RGBA纹理。质量低,但尺寸小,性能更佳。 16KB (2 bits per pixel) Android (PowerVR), iOS, tvOS.
RGB Compressed PVRTC 4 bits 压缩RGB纹理。高质量的纹理,特别是在颜色数据上,但是需要很长时间来压缩。 32KB (4 bits per pixel) Android (PowerVR), iOS, tvOS.
RGBA Compressed PVRTC 4 bits 压缩RGB纹理。高质量的纹理,特别是在颜色数据上,但是需要很长时间来压缩。 32KB (4 bits per pixel) Android (PowerVR), iOS, tvOS.
RGB Compressed ATC

压缩RGB纹理。

32KB (4 bits per pixel) Android (Qualcomm - Adreno), iOS, tvOS.
RGBA Compressed ATC

压缩RGBA纹理。

64KB (8 bits per pixel) Android (Qualcomm - Adreno), iOS, tvOS.
RGB 16 bit

65万种没有阿尔法的颜色。使用比压缩格式更多的内存,但是更适合于UI

或者没有渐变的脆纹理。

128KB (16 bits per pixel) All platforms.
RGB 24 bit 真正的颜色,但没有alpha。 192KB (24 bits per pixel) All platforms
Alpha 8 高质量的alpha通道,但没有任何颜色。 64KB (8 bits per pixel) All platforms.
RGBA 16 bit 低质量的真实颜色。这是具有alpha通道的纹理的默认压缩。 128KB (16 bits per pixel) All platforms.
RGBA 32 bit 真正的颜色和alpha。这是具有alpha通道的纹理的最高质量压缩。 256KB (32 bits per pixel) All platforms.

转自:漫世界
原文链接:https://www.cnblogs.com/dingzhaoliang/p/12149598.html

最新文章