Unity 优化翻译官方文档(二) ------ 平台特定覆盖的纹理压缩格式

20 篇文章 4 订阅

   官方文档 : https://docs.unity3d.com/Manual/class-TextureImporterOverride.html


虽然Unity支持许多常见的图像格式作为导入纹理的源文件(如JPG、PNG、PSD和TGA),这些格式在实时呈现过程中没有使用。通过3D图形硬件,如图形卡或移动设备。3D图形硬件要求纹理以专门的格式进行压缩,以优化快速纹理采样。各种不同的平台和设备都有各自不同的专有格式。默认情况下,Unity编辑器会自动将纹理转换为最合适的格式,以匹配构建目标你已经选择了。只有转换后的纹理包含在您的构建中;你的资产来源文件以原始格式保存在项目的资产文件夹中。然而,在大多数平台上,有许多不同的受支持的纹理压缩格式可供选择。统一为每个平台有一定的默认格式设置,但在某些情况下,您可能想要覆盖默认的,选择一个不同的你的一些纹理压缩格式(例如,如果您正在使用一个纹理作为一个面具,只有一个频道,您可以选择使用BC4格式以节省空间,同时保留质量)。

要为每个平台应用自定义设置,请使用纹理导入器设置默认选项,然后使用特定于平台的覆盖面板来覆盖特定平台的缺省选项。

Default internal Texture representation per platform

1.下表展示了每个平台使用的默认格式

PlatformColor modelNoneNormal quality (Default)High qualityLow quality (higher performance)
Windows, Linux, macOS, PS4
XBox One
RGBRGB 24 bitRGB Compressed DXT1RGB(A) Compressed BC7RGB Compressed DXT1
 RGBARGBA 32 bitRGBA Compressed DXT5RGB(A) Compressed BC7RGBA Compressed DXT5
 HDRRGBA HalfRGB Compressed BC6HRGB Compressed BC6HRGB Compressed BC6H
WebGLRGBRGB 24 bitRGB Compressed DXT1RGB Compressed DXT1RGB Compressed DXT1
 RGBARGBA 32 bitRGBA Compressed DXT5RGBA Compressed DXT5RGBA Compressed DXT5
Android (default subTarget)RGBRGB 24 bitRGB Compressed ETCRGB Compressed ETCRGB Compressed ETC
 RGBARGBA 32 bitRGBA Compressed ETC2RGBA Compressed ETC2RGBA Compressed ETC2
iOSRGBRGB 24 bitRGB Compressed PVRTC 4 bitsRGB Compressed PVRTC 4 bitsRGB Compressed PVRTC 2 bits
 RGBARGBA 32 bitRGBA Compressed PVRTC 4 bitsRGBA Compressed PVRTC 4 bitsRGBA Compressed PVRTC 2 bits
tvOSRGBRGB 24 bitRGB Compressed ASTC 6x6 blockRGB Compressed ASTC 4x4 blockRGB Compressed ASTC 8x8 block
 RGBARGBA 32 bitRGBA Compressed ASTC 6x6 blockRGBA Compressed ASTC 4x4 blockRGBA Compressed ASTC 8x8 block
 RGBARGBA 32 bitRGBA 16 bitRGBA 16 bitRGBA 16 bit

2.所有支持的纹理压缩格式

下表显示了每个平台上可用的纹理压缩格式选项,以及产生的压缩文件大小(基于256 px-square图像)。选择纹理压缩格式是文件大小和质量之间的平衡;质量越高,文件的大小就越大。在下面的描述中,查看游戏内纹理的最终文件大小为256像素,256像素。

当您使用在目标平台上不支持的纹理压缩格式时,纹理会被解压到RGBA 32中,并将其存储在内存中,与压缩的纹理一起存储。当这种情况发生时,时间就会失去解压缩纹理,而内存丢失,因为您将它们存储两次。此外,所有平台都有不同的硬件,并对特定的压缩格式进行了优化,以最有效地工作;选择不兼容的格式会影响游戏的性能。下面的表格显示了每种压缩格式的支持平台。

下表说明:

  • RGB是一种颜色模型,在这种模型中,红色、绿色和蓝色以不同的方式组合在一起,以重现广泛的颜色。
  • RGBA是一个带有阿尔法通道的RGB模式,它支持混合和不透明度的改变。
  • 压缩压缩是一种有损压缩格式(意味着数据的某些部分在压缩过程中丢失)在DXT或其他纹理压缩之上。纹理在CPU上被解压到DXT或其他,然后在运行时将其上传到GPU上。压缩压缩可以帮助纹理在磁盘和下载中使用尽可能低的空间。嘎吱作响的纹理需要很长时间来压缩,但是在运行时的减压是非常快的。
Texture compression formatDescriptionSize 
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.

您可以从DDS文件中导入纹理,但是只支持DXT、BC压缩格式或未压缩的像素格式。

3.Android注意事项

除非您的目标是特定的硬件(如Tegra),否则ETC2压缩是Android最有效的选择,提供了质量和文件大小的最佳平衡(与相关的内存大小需求)。如果你需要一个alpha通道,你可以将它存储在外部,并且仍然可以从较低的材质文件大小中受益。

您可以使用ETC1来获得具有alpha通道的纹理,但前提是构建是针对Android的,并且纹理被放置在一个地图集上(通过指定包装标签)。为了实现这一点,请使用ETC1复选框为纹理进行压缩。Unity将生成的atlas分成两种纹理,每一种都没有alpha通道,然后将它们组合在渲染管道的最后部分中。

要在纹理中存储阿尔法通道,请使用RGBA16位压缩,这是由所有硬件供应商支持的

 

如果你看到这里,还不知道怎么优化,那么请看下面这篇文章 : 

           Unity游戏开发图片纹理压缩方案 : https://blog.csdn.net/goodai007/article/details/52679333

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值