Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sprite Packer tight packing algorithm is wasting a lot of space

Discussion in '2D' started by Wisteso, Mar 17, 2015.

  1. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    Hey guys

    Ive attached page two (p2) and page three (p3) of my atlases. The omitted first page looks a lot like the second page, so it was left out for brevity.

    spritepacker_p2.png spritepacker_p3.png

    Fortunately, this issue is pretty clear just by looking at the two screenshots. While the pages are clearly a little bit optimized, they are very far from optimal. The page (p3) with many small sprites could easily fit in the gaps of my other pages (p2 and omitted p1). While we use a custom packer policy, the issue occurs regardless of what packer policy is used.

    Fortunately these are compressed with PVRTC which reduces the memory impact of the waste, but its still somewhat concerning since texture memory is our biggest bottleneck.

    There are also other software packages that do a phenomenal job with packing like http://www.spriteuv.com/comparisonspritepacker and also prove that more efficient packing *can* be done.

    Unfortunately, I cant use a third party tool since other tools will not use dynamic meshes to reduce fill rate and increase atlas sprite density. Those that DO use dynamic meshes end up using "mesh renderer" components which would be pretty incompatible with all the work we've already done.

    Please help, Unity devs!
     
    Last edited: Mar 17, 2015
  2. Yukichu

    Yukichu

    Joined:
    Apr 2, 2013
    Posts:
    420
    Funny, I was trying to find out why the Unity sprite packer was ... less than efficient. Seriously.

    I have to pack everything into DefaultPackerPolicy for the uGUI. I don't understand why they'd make it so inefficient.
     
  3. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    I'm as surprised as you, Yukichu. It's actually a really major problem considering that mobile devices have very limited memory compared to PCs.

    I think it would be perfectly reasonable to provide an naïve packer if they allowed us to customize the algorithm, but since that is not possible, it's become a very serious issue that it is so inefficient.

    The strange thing is that Unity's packer seems perfectly capable of handling the geometric calculations. One of my example sheets has dozens of sprites packed efficiently. It almost seems like its a bug that causes it to give up optimization prematurely.
     
  4. joaobsneto

    joaobsneto

    Joined:
    Dec 10, 2009
    Posts:
    152
    I'm having the same issue in 5.3.2f1 :(
     
  5. ColossalPaul

    ColossalPaul

    Unity Technologies

    Joined:
    May 1, 2013
    Posts:
    174
    Do the big sprites and the smaller ones have the exact same import settings (mipmap, filter, ppu etc)?
     
  6. Wisteso

    Wisteso

    Joined:
    Nov 17, 2013
    Posts:
    50
    @ColossalPaul

    This was for an older version of Unity. The settings are all identical since they're set via code + grouped into atlases using an extended PackerPolicy (but I checked, and yes, the issue occurs with any PackerPolicy). The current version of Unity seems improved since my original post, though still not ideal as Joaobsneto confirmed.