Unity increases size of imported sprites

限于喜欢 提交于 2020-02-21 13:27:35

问题


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 ?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/23210866/unity-increases-size-of-imported-sprites

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!