“Tight Packing” should always be the most efficient packing method, but often when Tight Packing is enabled, the sprites are less efficiently packed (especially if any of the sprites are round). Here’s a simple example, where using Tight Packing packs the circles less efficiently and doubles the size of the texture atlas. Tested in Unity 2021.3.x.
I reported this issue to Unity QA; they falsely claimed that I had “Full Rect” enabled on some of my sprites and closed the bug report as invalid.
To ensure all sort of shapes & sprites work well with Sprite Atlas tight packing, the system is based on a simple way to ensure that the resulting square texture is as small as possible. Hence the above result is expected for that set of sprites. Thanks.
The above results is that the resulting texture is NOT as small as possible when “Tight Packing” is enabled. It’s twice as big as it should be because the sprites are not packed efficiently.
When packing rect sprites, we do not try to fit other sprites within the transparent area of previously fitted sprites. Besides we also do padding to ensure there are no artifacts when rendering tight-meshed sprites.
To ensure packing time is minimal Sprites are fitted in a single-pass (once fit in a texture its not revisited again) and uses simple hueristics. Yes, for the above case it may appear that Rect packing is better but this is not usually the case for all sort of inputs.
Also note that Tight-packing considers the Mesh of the sprite when packing and Rect packing only considers the rect of the Sprite even when Sprite import type is set to Tight-Mesh.
I am not sure if you understand the issue I am describing. To be entirely clear, in the above example, none of the circular sprites have their Mesh Type set to “Full Rect”. They are all set to “Tight”. The lefthand side of the image shows what happens when “Tight Packing” is disabled and the right half of the image shows what happens when “Tight Packing” is enabled.
If you’re saying that “Tight Packing” uses a one-pass packing algorithm that is not guaranteed to pack the sprites efficiently even when all of the sprites have their Mesh Type set to “Tight”, that is quite disappointing. Fast packing speed is nice, but for mobile it’s important to pack our sprites as efficiently as possible, to reduce build size, load times, and GPU memory usage. There should at least be an option to use a slower packing algorithm that packs the sprites more efficiently. Right now, we have to pack the atlas both ways and compare them to see which produces a smaller atlas, which is much slower than a multi-pass packing algorithm would be.