📜 ⬆️ ⬇️

Eliminating the artifacts of compression PVRTC textures

Problematics


In the development of mobile games, many are faced with the need to reduce the occupied memory or the size of the distribution. Most often the heaviest assets in the project are textures. Uncompressed texture size of 1024x1024 takes around 4 MB. And in the scene, usually such textures are not enough. And if we want our game scenes to load faster and not take up too much RAM, we have to compress the textures. There are several types of compression in unity3d for mobile devices. I think that the approach described here for improving the quality of the result of texture compression will be valid for all algorithms, but we will consider the example of PVRTC. He has one big plus and one big minus. The size of the textures is reduced to eight times, but at the same time there are terrible artifacts, especially on transparent textures. This topic is designed to help combat the latter.

Algorithm


The essence of the algorithm is the post-processing of textures before compression. To do this, we need a graphics editor that can work with layers. I used Adobe Photoshop. Consider the algorithm in detail:

1) Open the texture in Photoshop, and create a new layer on top of the existing one.
2) Fill it with a medium shade of gray.


')


3) Next on this layer impose a noise with the settings as shown:



4) Set the blending mode “Soft Light” and transparency from 30 to 50 percent in such a way that the noise is not very conspicuous, but still visible.



5) Save and import texture.



If the texture is translucent, just select the pixels from the source layer, invert the selection and remove the pixels from the noisy layer.

After the import, it remains only to specify the RGBA Compressed PVRTC 4bit compression. I strongly advise in the tabs of the importer iOs and Android, put a check mark Override and specify Best in Compression Quality. If your texture will be used for the GUI, uncheck Generate Mip Maps. This will relieve you of the “blur” effect if the UI element is located far enough away from the camera.

results



As you can see, all the artifacts are safely gone. Note the green stone and gear around the timer at the top.

Conclusion


Before using this simple method, I had to leave the textures for the GUI uncompressed, which is why the application often took up a lot of memory. But with this approach, it turns out to compress almost all the textures for the interfaces. In addition to very fine details, which still have to make on separate atlases and leave in RGBA TrueColor. But the memory savings are colossal. This approach was successfully applied in a joint project of Heyworks Unity Studio and iFree Innovations - DragonIt . All the graphic material provided in the article is based on textures from this project.

Source: https://habr.com/ru/post/158963/


All Articles