Compression là gì

While Unity supports many comtháng image formats as source files for importing your Textures (such as JPG, PNG, PSD and TGA), these formats are not used during realtime rendering by 3D graphics hardware such as a graphics card or Mobile device. 3D graphics hardware requires Textures to be compressed in specialized formats which are optimised for fast Texture sampling. The various different platforms & devices available each have sầu their own different proprietary formats.

You watching: Compression là gì

By default, the Unity Editor automatically converts Textures khổng lồ the most appropriate format lớn match the build target you have selected. Only the converted Textures are included in your build; your source Asset files are left in their original format, in your project’s Assets folder. However, on most platforms there are a number of different supported Texture compression formats to lớn choose from. Unity has certain mặc định formats set up for each platkhung, but in some situations you may want lớn override the default and pichồng a different compression format for some of your Textures (for example, if you are using a Texture as a mask, with only one channel, you might choose to use the BC4 format lớn save space while preserving quality).

To apply custom settings for each platsize, use the Texture Importer lớn phối default options, then use the Platform-specific overrides panel to override those defaults for specific platforms.

*
Default internal Texture representation per platform

The following table shows the mặc định formats used for each platsize.

PlatformMàu sắc modelNoneNormal chất lượng (Default)High qualityLow chất lượng (higher performance)
Windows, Linux, macOS, PS4, XBox OneRGBRGB 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 (mặc định 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

All supported Texture compression formats

The following table shows the Texture compression format options available on each platsize, & the resulting compressed tệp tin kích thước (based on a 256px-square image). Choosing a Texture compression format is a balance between tệp tin kích thước & quality; the higher the chất lượng, the greater the file form size. In the mô tả tìm kiếm below, see the final file form size of a in-game Texture of 256 by 256 pixels.

When you use a Texture compression format that is not supported on the target platform, the Textures are decompressed khổng lồ RGBA 32 and stored in memory alongside the compressed Textures. When this happens, time is lost decompressing Textures, and memory is lost because you are storing them twice. In addition, all platforms have sầu different hardware, và are optimised to work most efficiently with specific compression formats; choosing non-compatible formats can impact your game’s performance. The table below shows supported platforms for each compression format.

Notes on the table below:

RGBA is a version of RGB with an alpha channel, which supports blending và opathành phố alteration.

Texture compression formatDescripciónSize for a 256x256 px TextureSoporte de Plataforma
RGB Compressed DXT1Compressed unsigned normalised integer RGB Texture.32KB (4 bits per pixel)Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra và Intel Bay Trail), WebGL Note: With linear rendering on website browser that doesn’t support sRGB DXT, textures are uncompressed at run time to lớn RGBA32.
RGB Crunched DXT1Similar to RGB Compressed DXT1, but compressed using Crunch compression. See Notes, above sầu, for more on crunch compression.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 website browser that doesn’t support sRGB DXT, textures are uncompressed at run time to lớn RGBA32.
RGBA Compressed DXT5Compressed unsigned normalised integer RGBA Texture. 8 bits per px.64KB (8 bits per pixel)Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra & Hãng sản xuất Intel Bay Trail), WebGL Note: With linear rendering on a website browser that doesn’t tư vấn sRGB DXT, textures are uncompressed at run time to lớn RGBA32.
RGBA Crunched DXT5Similar to lớn RGBA Compressed DXT5, but compressed using Crunch compression. See Notes, above sầu, for more on crunch compression.Variable, depending on the complexity of the content in the texture.Windows, Linux, macOS, PS4, XBox One, Android (Nvidia Tegra & Hãng sản xuất 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 lớn RGBA32.
RGB Compressed BC6HCompressed unsigned float/High Dynamic Range (HDR) RGB Texture.64KB (8 bits per pixel)Windows Direct3D 11: OpenGL 4, Linux. Note: BC6H Textures are uncompressed at run time lớn RGBA half on the following platform configurations: - macOS with OpenGL- Platforms with Direct3D 10 Shader Model 4 or OpenGL 3 GPUs.
RGB(A) Compressed BC7High-unique compressed unsigned normalised integer RGB or RGBA Texture.64KB (8 bits per pixel)Windows Direct3 chiều 11: OpenGL 4, Linux Note: BC7 Textures are uncompressed at run time to RGBA 32bits on the following platkhung configurations: - macOS with OpenGL- Platforms with Direct3D 10 Shader Model 4Platforms with OpenGL 3 GPUs.
RGB Compressed ETCCompressed RGB Texture. This is the default texture compression format for textures without an altrộn channel for Android projects.32KB (4 bits per pixel)Android, iOS, tvOS.Note: ETC1 is supported by all OpenGL ES 2.0 GPUs. It does not support altrộn.
RGB Crunched ETCSimilar khổng lồ RGB Compressed ETC, but compressed using Crunch compression. See Notes above for more on crunch compression.Variable, depending on the complexity of the content in the texture.Android, iOS, tvOS.
RGB Compressed ETC2Compressed RGB Texture.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 khổng lồ the format specified by ETC2 fallback in the Build Settings.
RGBA Compressed ETC2Compressed RGBA Texture. This is the mặc định Texture compression format for textures with alpha channel for Android projects.64KB (8 bits per pixel)Android (OpenGL ES 3.0), iOS (OpenGL ES 3.0), tvOS (OpenGL ES 3.0) Note: On iOS và tvOS devices that don’t tư vấn ETC2, the texture is uncompressed at run time khổng lồ RGBA32. On Android platforms that don’t support ETC2, the texture is uncompressed at run time lớn the format specified by ETC2 fallback in the Build Settings.
RGBA Crunched ETC2Similar to lớn RGBA Compressed ETC2, but compressed using Crunch compression. See Notes above sầu for more on crunch compression.Variable, depending on the complexity of the content in the texture.

See more: Nữ Sinh Năm 1992 Là Tuổi Gì, Tuổi Con Gì, Mạng Hợp Với Những Gì?

Android (OpenGL ES 3.0), iOS (OpenGL ES 3.0), tvOS (OpenGL ES 3.0) Note: On iOS & tvOS devices that don’t tư vấn ETC2, the texture is uncompressed at run time lớn 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 ASTCVariable blochồng size compressed RGB Texture.12x12: 0.89 bits per px (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 ASTCVariable bloông xã kích thước compressed RGBA Texture.12x12: 0.89 bits per pixel (7744 bytes for a 256x256 Texture)10x10: 1.28 bits per px (10816 bytes for a 256x256 Textures)8x8: 2 bits per pixel (16KB for a 256x256 Texture); 6x6: 3.56 bits per px (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 bitsHigh-compression RGB Texture. Low unique, but lower form size, resulting in higher performance.16KB (2 bits per pixel)Android (PowerVR), iOS, tvOS.
RGBA Compressed PVRTC 2 bitsHigh-compression RGBA Texture. Low quality, but lower form size, resulting in higher performance.16KB (2 bits per pixel)Android (PowerVR), iOS, tvOS.
RGB Compressed PVRTC 4 bitsCompressed RGB Texture. High-unique Textures, particularly on color data, but can take a long time khổng lồ compress.32KB (4 bits per pixel)Android (PowerVR), iOS, tvOS.
RGBA Compressed PVRTC 4 bitsCompressed RGB Texture. High-quality Textures, particularly on color data, but can take a long time to compress.32KB (4 bits per pixel)Android (PowerVR), iOS, tvOS.
RGB Compressed ATCCompressed RGB Texture.32KB (4 bits per pixel)Android (Qualcomm - Adreno), iOS, tvOS.
RGBA Compressed ATCCompressed RGBA Texture.64KB (8 bits per pixel)Android (Qualcomm - Adreno), iOS, tvOS.
RGB 16 bit65 thousvà colors with no alpha. Uses more memory than the compressed formats, but could be more suitable for UI or crisp Textures without gradients.128KB (16 bits per pixel)All platforms.
RGB 24 bitTrue color, but without altrộn.192KB (24 bits per pixel)All platforms
Altrộn 8High-chất lượng altrộn channel, but without any color.64KB (8 bits per pixel)All platforms.
RGBA 16 bitLow-unique true color. This is the default compression for Textures that have an altrộn channel.128KB (16 bits per pixel)All platforms.
RGBA 32 bitTrue color with altrộn. This is the highest quality compression for Textures that have sầu an altrộn channel.256KB (32 bits per pixel)All platforms.

You can import Textures from DDS files, but only DXT, BC compressed formats, or uncompressed px formats are supported.

Notes on Android

Unless you’re targeting specific hardware (such as Tegra), ETC2 compression is the most efficient option for Android, offering the best balance of chất lượng & file kích thước (with associated memory size requirements). If you need an altrộn channel, you could store it externally & still benefit from a lower Texture file form size.

You can use ETC1 for Textures that have an altrộn channel, but only if the build is for Android & the Textures are placed on an atlas (by specifying the packing tag). To enable this, tick the Compress using ETC1 checkbox for the Texture. Unity splits the resulting atlas into two Textures, each without an alpha channel, and then combines them in the final parts of the render pipeline.

See more: Là Gì? Nghĩa Của Từ Mái Che Tiếng Anh Là Gì ? Mái Che Tiếng Anh Là Gì

To store an altrộn channel in a Texture, use RGBA16 bit compression, which is supported by all hardware vendors.


Chuyên mục: Giải Đáp