Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity increases size of imported sprites

Tags:

unity3d

sprite

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 ?

like image 428
Khayam Gondal Avatar asked Apr 22 '14 05:04

Khayam Gondal


People also ask

Why is my sprite size so small?

If it's set to 1024 and your sprite is 2048 pixels, for example, it will shrink your sprite to be 1024 pixels (keeping height/width proportion). This could make your sprite smaller than you expected. One other thing in the Camera settings, I mentioned before there is a parameter called orthographic size.

How many pixels per meter does a sprite take up?

Pixels To Units: This tells Unity how many pixels in your sprite will take 1 meter in the game world. If your camera's orthographic size is 5 meters, then you'll see 10 meters on screen top to bottom. If your sprite is set to 100 pixels per meter (default), then each 100 pixels in your sprite will occupy one tenth of the screen height.

What determines the size of a unity texture?

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?


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.

like image 76
kreys Avatar answered Sep 19 '22 23:09

kreys


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.

like image 29
Roberto Avatar answered Sep 19 '22 23:09

Roberto