
1. Introduction of the ASTC Texture Compression Format
ASTC is an industry-leading texture compression format produced in mid-2012 after the emergence of OpenGL ES 3.0. Its compression blocks can be compressed from 4×4 to 12×12 to less than 1 bit for each pixel. There are many compression ratios to select from. The ASTC format supports RGBA and is suitable for power-of-2 aspect ratio dimensions and NPOT (non-power-of-two) textures with no size requirements.
Taking the ASTC 4×4 block compression format as an example; if each pixel occupies 1 byte with 8 bits, the compressed size of a texture in 1024×1024 is 1MB. ASTC has great advantages in compression quality and capacity.
There are detailed test data in the document: https://developer.nvidia.com/astc-texture-compression-for-game-assets
2. Compatible Models
- iOS
Apple started to support ASTC from the A8 processor. It is supported by iOS devices above iPhone6 and iPad mini 4, but not supported by iPhone 5s in 2014 and devices before iPad mini 3.
- Android
Android’s mainstream compression format is shifting from ETC2 to ASTC. Unity’s official description of the ASTC format supported in Android:
https://docs.unity3d.com/Manual/class-TextureImporterOverride.html
The official document mentions that all GPUs that support OpenGL ES 3.1 and some that support OpenGL ES 3.0 support ASTC.
In view of the uncertainty of OpenGL ES 3.0 GPU, we conducted ASTC format compatibility tests on some low-profile models with a high proportion of current users, and added some GPU models with low proportion Mali-G71, Adreno 306, Adreno 308, and Adreno 405 for testing (test time 2020.5.21):
Texture Compression ASTC Platform Support:tvOS (all), iOS (A8), Android (PowerVR 6XT, Mali T600 series, Adreno 400 series, Tegra K1)
Most of the models on the market support OpenGL ES 3.1 or above. A few models with low GPU configuration support OpenGL ES 3.0 but do not support the ASTC compression format. The market share in April 2020 is less than 1.5%. From a personal point of view See the ASTC compression format is widely used.
Supplement: Support for the ASTC compression format is introduced in Unity official documentation version 2018.4.
Texture Compression ASTC Platform Support: tvOS (all), iOS (A8), Android (PowerVR 6XT, Mali T600 series, Adreno 400 series, Tegra K1)
3. Choice of compression format
In the previous article, we learned about Bits Per Pixel in different ASTC formats. For a more intuitive feeling, we will use a texture that is prone to compression distortion as an example.
- Comparison of compression results and capacities of ASTC and ETC2 formats
As can be seen from the figure above, the capacity of a 512×512 texture map (without Alpha channel and with Mipmap turned on) is 1MB, and the capacity after being compressed into ETC2 4 bits is 170.7KB, with obvious distortion, and the capacity after being compressed into ASTC 6×6 is 154.7 KB with no obvious distortion, the capacity of ASTC 6×6 is smaller than that of ETC2 4 bits, and the compression quality is higher than that of ETC2 4 bits.
As can be seen from the figure above, the capacity after being compressed into ASTC 8×8 is 85.4KB, which is about 50% of that of ETC2 4 bits, and the compression quality is higher than that of ETC2 4 bits.
- The compression format choice for No Alpha Channel, RGB 24 bit/pixel
As can be seen from the figure above, a 512×512 size map (without Alpha channel) has no obvious distortion after being compressed into ASTC 6×6, ASTC 8×8, and ASTC 10×10, and the capacity after being compressed into ASTC 8×8 is reduced compared with ASTC 6×6 About 44.8%, after compressing to ASTC 10×10, the capacity is reduced by about 33.7% compared with ASTC 8×8.
Take the normal map as an example:
As can be seen from the figure above, a normal map with a size of 512×512, compressed into ASTC 4×4, has no obvious distortion, compressed into ASTC 5×5, the distortion is visible to the naked eye, and compressed into ASTC 6×6, the distortion is obvious.
Take facial textures as an example:
As can be seen from the figure above, there is no obvious distortion when compressed to ASTC 6×6, and the distortion is visible to the naked eye after being compressed to ASTC 8×8.
Conclusion: The recommended compression format for textures without alpha channels is ASTC 8×8. If the texture is a normal map, the recommended compression format is ASTC 5×5. For textures with higher requirements (such as the face, and scene ground), you can set the compression format to ASTC 6×6, and the normal map to ASTC 4×4.
Conclusion compared with NV document data:
Light green indicates the benchmark recommendation, and dark green indicates the recommendation with higher requirements. The only difference is whether to choose ASTC 6×6 or ASTC 8×8 for the compression of ordinary textures. From a personal point of view, the recommendation index of 8×8 should be 0.
- With Alpha channel, RGBA 32-bit/pixel compression precision selection
As can be seen from the figure above, the distortion is visible to the naked eye after being compressed to ASTC 5×5, and there is obvious distortion after being compressed to ASTC 6×6, and the capacity after being compressed to ASTC 5×5 is reduced by about 34.9% compared with ASTC 4×4. Under the same compression format, the quality of compression with an Alpha channel is significantly lower than that without an Alpha channel.
Conclusion: The recommended compression format for textures with alpha channels is ASTC 5×5. For textures with higher requirements (such as special effects, and UI), you can set the compression format to ASTC 4×4.
The conclusion is consistent with the comparison of NV document data:
- The effect of an alpha channel on the compression
Under the same compression format, the texture capacity remains the same, whether there is an alpha channel has a great impact on the compression result, and the compression quality of the texture with the alpha channel decreases.
It can be seen from the above figure that for a 32-bit image with an alpha channel and a 24-bit image without an alpha channel, when the same compression format is applied, the compression results are quite different.
For a 32-bit image with an Alpha channel, select the Alpha Source in the Import Settings as None, the compression result of which is the same as that without an Alpha channel.
- Other issues
1) Impact on Shader
When the default texture is “black”, if the texture is the default, the default value is (0,0,0,0), and the A channel reads 0; when using RGB ETC2 4bits format, the A channel reads 0; using ASTC format, channel A is read as 1. Here we should pay attention to the consideration of the Shader default value.
2) The JPEG format is already a lossy format, the precision lost in JPEG has nothing to do with ASTC compression.
3) Regarding the texture size
When the compression format supports non-powers of 2, as long as the hardware supports the compression format, NPOT textures can be used. However, power-of-2 textures are better than other sizes, and there are complex graphics factors here.
To understand simply, textures are stored in units of blocks in the GPU. In order to save memory and bandwidth as much as possible, the compression format also stores textures in blocks. In recursion or looping, if a number is a power of 2, it is divisible by 2, and the quotient is also a power of 2. The OpenGL API supports non-powers of 2 because the details are hidden for ease of use, and some necessary stretching or filling operations are handled internally. Therefore, when there is no special requirement, try to use POT textures, and try to make them according to the actual application size when making them, so as to avoid some high-precision compression to low-precision situations.
4) Regardless of whether the texture itself has Alpha information, the different settings of ASTC compression directly determine the compression size. Controlling the package size of texture resources depends on whether the specifications of the ASTC compression format are reasonable. After all, the capacity after compression to ASTC 8×8 is reduced by about 44.8% compared with ASTC 6×6 (85.4KB vs 154.7KB), and the capacity after compression to ASTC 8×8 About 300% smaller than ASTC 4×4 (85.4KB vs 341.4KB). And we usually check whether the Alpha channel is empty, which can help us judge whether the Alpha information is redundant and whether we should set a lower compression precision.
5) The ASTC compression algorithm is smarter, it will assign higher weights to the more variable channel RGB or A, and for a monochrome image, when the content of the RGB channel is the same, a lower pixel occupancy can be used to achieve a good Effect. For monochrome images, there is no need to use the R8 compression format. Instead, the RGB channels should be filled with the same information, and the ASTC pixel ratio should be lower, such as ASTC 8×8.
6) In the actual use of the project, it is found that for the normal map, the compression effect of ETC2 4bits is better than that of ASTC 5×5. For the map with a transparent channel, there is a situation where ETC2 8 Bits is better than ASTC 4×4, which was missed in the test before. For comparison, the further comparison is needed, and selection is made according to the actual situation. If the A channel has more details, choose ASTC, and if the A channel has fewer details, choose ETC2.
Author: Ssiya, https://www.zhihu.com/people/ssiya-330
Translation: UWA Tech
Thanks to the author Ssiya for contributing. Welcome to share, please do not reprint without the authorization of the author.
YOU MAY ALSO LIKE!!!
UWA Website: https://en.uwa4d.com
UWA Blogs: https://blog.en.uwa4d.com
UWA Product: https://en.uwa4d.com/feature/got
You may also like
-
Dynamic Resolution in Games from Principle to Application
January 4, 2023 -
Introduction of the Raytracing Technology Part 2
December 21, 2022