I had imported a .png (800 x 294) Size 37.2 KB into unity but after importing it shows it size 0.9MB, which is too large than original. I changed the Max Size for 1024 to 512 in import settings which lowers it resolution from original to 512 x 188 with size of 94KB. How does .png size increased this much (from 37.2K to 0.9MB) without any image resolution changes ?
-
I think this could be linked to this [question](http://gamedev.stackexchange.com/questions/93115/loading-images-using-their-bytes-in-unity). – JohnTube Jul 04 '15 at 23:52
2 Answers
You are probably misleading the physical texture size of the png, which is 37.2 KB as you specified, with a texture size in the memory.
It dosen't matter, if your file is jpg, png, or psd, in game memory it will take as much size as you specify. If you specify maximum quality, which is uncompressed 32bit RGBA, then it will take 800 x 294 x 4 bytes (32 bits) = 235 200 x 4 bytes = 940 800 bytes = ~0.9 MB
If you want use less memory, you can decrease the quality to 16bits (4 bits per channel), or use compressed in memory types, however, it requires the texture to have power of two dimensions, and to be square (on iOS). Then in this case, you will have 1024 x 1024 x 0.5 bytes (4 bits per pixel PVRTC4) = 524 288 bytes = ~0.5 MB
These compressed textures are kept compressed in the GPU memory. There is available PVRTC compression on PowerVR's GPUs and DXTn compression on many other. By using them, you will decrease your memory usage, and also the rendering time - there is less data to be processed. They're not as perfect as 32bit RGBA, but they're often better than 16bit RGBA - you should check the visuals by yourself.
If you want some more detailed information about textures compression, take a look also at this thread.
To sum up, the size displayed by unity is size of texture in memory, which has nothing to do with source file type or size, the only thing that is important is import type (compression) and max size limit.
-
hey how do in-memory compressed images work? When are they effectively decompressed? – Roberto Apr 24 '14 at 03:20
-
1They're kept compressed in the GPU memory, so they're never decompressed. I've updated the answer with some more data. – kreys Apr 24 '14 at 07:20
-
2More precisely, they are decoded on the fly by graphics hardware. Because of this there's no negative performance impact; in fact using them can *increase* performance (depending on your bottlenecks), because of reduced memory bandwidth. – Arttu Peltonen Apr 24 '14 at 07:23
-
In-GPU is not equal to in-storage. For some simple games it's more important to have 20 mb of png decoded by CPU on scene start, not 400 mb of some GPU stuff on the drive. Because mobile users can have 16 gigs devices or no WiFi nearby. – Alexander Ulitin Dec 11 '15 at 01:41
It's because of the compression settings. Change the Texture Type to Advanced and will be able to see the various color formats the texture can have (in the Format setting). Changing the color format have a big impact in the texture memory size.

- 11,557
- 16
- 54
- 68