As of 5.1 (I think) there is the new compression import option for textures called crunched. It brings the memory footprint (and build size I think) for the texture down to less than half from the normal compressed setting. This seems like a really huge deal and I know it was listed in the road map, but I can’t find any more information on it. Nobody seems to be talking about it. Are there drawbacks? Is there some cpu/gpu overhead for using these highly compressed textures? Visually it looks very similar! Will I see certain artifacts in specific situations? It seems too good to be true, and I’m looking for the catch.
In case you didn’t find this already, here is the description you can find in the TextureImporter documentation:
Crunch is a lossy compression format on top of DXTR texture compression. Textures will be converted to DXT when uploading the GPU at runtime. Crunch compression helps achieving the lowest possible size footprint on disk and for downloads. Crunch textures can take very long to compress, but decompression at runtime is very fast.
If you use compressed asset bundles, I can’t imagine using crunched textures make a big size difference.
@Peter77 So the size of the texture in memory during runtime is the same? Its just for build size?
In case anyone is curious my game built was 400 mb, I set almost all my textures to crunch and now its 320 mb. Takes a LONG time to import textures when they are set to crunch so while I’m iterating on some textures I’ll leave them on compressed.
That’s how I understand it and what makes the most sense to me. It’s definitely like this on the GPU.
I’m not sure whether Unity keeps the compressed or uncompressed texture in main memory when Read/Write Enabled is activated in the texture import settings. My best guess would be that they keep the uncompressed data in memory (hopefully not both).
As I understand the crunched format, the only benefit is that it requires less space on disk. You basically trade longer build times, more or different texture compression artifacts and decompression during runtime for a smaller installation size.
Since the crunched format uses a lossy compression, be aware that you should not use it for all textures. Especially textures that encode data rather than colors could yield wrong results. Think of normal maps for example.
Is is possible to crunch a texture at runtime similar to how you can compress a texture at run time ? If it isn’t possible then i would like to know why. I know it time intensive operation but its still very useful if you had a some kinda import texture facility in your game that you wanted to prepare to store on a disk or database for file size or download optimization.
I know there is a crunch library but i did try using that but when i tried loading that texture unity gave an incompatible version error using its latest engine 2018.1. Does anyone know much about the status of this crunch facility ?
I have a runtime crunch version working now for DXT1/5 from the Unity Fork on GitHub. Its an unmanaged DLL (crnlib) but works very stable linked to my desktop windows 10 applications. I would be prepared to put it on the asset store if there was a call for it.
Because of the way I’ve written it the inputs are a uint32 array of color32 values. This means it can be called on against non compressed textures. It can generate mipmaps.
The benefits are that you can generate CRN byte arrays that are independent of unity internal version changes to this library which are essential if your data is on a remote server in a game. Also you can’t currently generate crunch textures at runtime with the latest version of unity.
I’m using crunch on ETC2 (Unity supports it now) and measuring the memory in the device I can see that the texture uses the exact same amount of RAM as when they were not crunched, which confirms what you said.
But when reading a post of Robert Basler (the guy who created crunch compression) I saw this:
“The goal is to reduce the amount of GPU memory required for textures. The reason for that is that I am going to be drastically increasing the amount of textures in the game in the coming weeks as I do a major overhaul to Miranda’s rendering and art, and according to Steam, 14.48% of gamers still have only 1GB of VRAM. The two weeks adding support for DXT texture compression are for those people. For the 2.76% of players with less than 1GB of VRAM, Miranda isn’t going to work any longer after the next update.”
So I’m confused. Is the memory in the detailed unity profiler not the memory used by the GPU in android devices? Do they get loaded into RAM and them loaded into VRAM? That doesn’t make much sense for me.
I understand the DXT crunched texture process like this (I guess ETC works similar or the same):
-
Crunch texture is loaded from disk to RAM
-
Compressed data is transcoded into DXT format (crnlib was designed to be quickly transcodable directly to DXTn with no intermediate recompression step)
-
DXT data is uploaded to VRAM
If the texture uses the “Read/Write Enable” option, a copy of the DXT data is kept in RAM, doubling the amount of memory.
https://docs.unity3d.com/Manual/BestPracticeUnderstandingPerformanceInUnity4.html
I believe the Unity Profiler might show mixed data. Take this with a grain of salt:
-
If texture uses “Read/Write Enable”, then Unity profiler shows the RAM+VRAM memory
-
If texture does not use “Read/Write Enable”, then Unity profiler shows the VRAM memory
I would double-check this with an actual GPU profiler from the platform vendor though. For Android I believe it’s “Adreno” and/or “Snapdragon” and for iOS it’s just XCode (Instruments).
BTW, here are a few links on the Crunch topic: