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

Efficient sprite atlas packing

Discussion in '2D' started by PixelSquad, Feb 26, 2015.

  1. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
    Hi guys

    The fact that each image in our atlases currently needs to be a rectangle causes a lot of texture space to be wasted in our game. So I started looking for a tool that can pack any shape of textures (not just rectangles) efficiently.

    On top of that I'd prefer that tool to be written in C# so that it can be integrated easily to our pipeline and used by our team regardless if it's a mac or windows pc workstation.

    The closest I got so far is this library, which is windows only at the moment: https://msdn.microsoft.com/en-us/library/windows/desktop/bb206321(v=vs.85).aspx

    Did anyone have to solve a similar problem in the past? Thanks a lot
     

    Attached Files:

  2. PixelSquad

    PixelSquad

    Joined:
    Sep 4, 2014
    Posts:
    114
    I thought of something for this one too. We could split each large sprite into several smaller quads, and discard large regions with alpha. This would allow the texture to be packed more efficiently. The only problem I thought is that since the position of the quads will vary in the atlas, we may need to add a border with two extra pixels of the original texture of each quad to avoid ugly seems due to bilinear filtering... If anyone is interested in this one I can tell you the results once I've implemented it, which may take a while again.
     
  3. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    there are already tools/assets that do this.. plus doesnt unity itself do this?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    Unity Pro already has the option to create a tight mesh for sprites, as well as packing sprites without necessarily using rects. http://docs.unity3d.com/Manual/SpritePacker.html

    --Eric