Search Unity

Unity free and sprite packing.

Discussion in '2D' started by hexdump, Nov 14, 2013.

  1. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Hi!,

    I have been reading about the great new 2d features in unity3d and there's something I'm not sure about: I use unity3d indie for ios and android. This devices are limited related to draw calls. If unity does not pack the sprites I import into it (creates a sprite sheet from them), does this mean I will have a draw call per sprite if they are all imported as diferent textures?

    Thanks in advance.
     
  2. Ilingis

    Ilingis

    Joined:
    Dec 13, 2012
    Posts:
    63
    You can pack those sprites into one in a painting software and then in Unity (in import settings) you can unpack them into single sprites by selecting Multiple in Sprite Mode (making it a texture atlas that is fully editable in a Sprite Editor window). That means if you have all of them on screen it costs you only 1 draw call.
     
  3. hexdump

    hexdump

    Joined:
    Dec 29, 2008
    Posts:
    443
    Thanks
     
  4. Lukas H

    Lukas H

    Joined:
    Jan 16, 2009
    Posts:
    394
    Just so you know, sprite packing is a Pro only feature.
     
  5. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Not true, it will render every single sprite sprite, even if it is the same one, with a drawcall. This is so bad that the default tutorial wouldn't even run well on my tablet as it has over 30 drawcalls.

    So unless this is a bug, it seems that the 2D system is mostly useless on mobile (unless you buy $4500 worth of software).
     
    Last edited: Nov 15, 2013
  6. Ilingis

    Ilingis

    Joined:
    Dec 13, 2012
    Posts:
    63
    I have the same amount of drawcalls whenever I add another part of my sprite on the screen (by sprite I mean one part of the big texture atlas sprite, each one is an object with a Sprite renderer attached).
     
  7. hamstar

    hamstar

    Joined:
    Sep 25, 2013
    Posts:
    84
    When I tested it out it seemed to work OK for me (not on pro). But I haven't tested in Build.

    I used a texture with import settings Sprite - Multiple,making two texture "slices" in the Sprite Editor. I created two sprite game objects, each using a different texture (slice).

    Stats when playing:
    Draw Calls 1, Saved by batching: 1

    Do you have Sprite Packer enabled in Editor Settings?
     
  8. dookie-boy

    dookie-boy

    Joined:
    Nov 29, 2012
    Posts:
    7
    Wait, from what I understand, the Sprite Packer is a Pro Only Preview, so it will be available for Unity Free too. In the future.

    Here it says:
    ...with one exception, all our new 2D features are currently available in the free version of Unity
    And then:
    - Save on textures with automatic atlas generation (Pro preview)
    - Optimize your fillrate with alpha cutout (Pro only)
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, even with sprite packing disabled it automatically combines sprites using the same texture. I can see this by making a sprite, duplicating it a few times, and the "saved by batching" number in the stats goes up while the draw calls remain at 1.

    --Eric
     
  10. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Looks like batching breaks if the object has a collider on it.

    Plain sprites do indeed batch just fine, wether it's the exact same sprite or just atlassed. Put a collider on it? Every sprite now has it's own drawcall.

    EDIT: My problems are indeed due to a bug, but it's not the collider. I have absolutely no idea what is triggering it and I cannot replicate it in a new scene.
     
    Last edited: Nov 15, 2013
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    What sort of collider? I tried circle/box/polygon colliders and still have batching.

    --Eric
     
  12. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Yeah, I've been trying to replicate the bug but I can't nail it down. I've sent in a bug report, because in a new scene it does indeed batch.
     
  13. rockpin-games

    rockpin-games

    Joined:
    Feb 4, 2013
    Posts:
    17
    Can anyone confirm this is really cominf for free users? If so does anyone know when?
    Thanks.
     
  14. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Sprite Packer is a Pro Only feature. The wording on that page is not perfect.
    Free users can still use atlases created using 3rd party software.

    Currently there are no plans to enable this in Unity Free.
     
  15. dookie-boy

    dookie-boy

    Joined:
    Nov 29, 2012
    Posts:
    7
    So, instead of importing separated spritesheets on Unity Free, I should make an atlas with lots of sprites before, and import that?
     
  16. JohnGallet

    JohnGallet

    Joined:
    Sep 27, 2013
    Posts:
    16
    There are some sprite batching tools in the asset store...costs about $15 I think, works on pro and free.
     
  17. Mindbogglegames

    Mindbogglegames

    Joined:
    Jun 15, 2013
    Posts:
    7
    rakkarage likes this.
  18. marceloSpiezzi

    marceloSpiezzi

    Joined:
    Nov 12, 2012
    Posts:
    6
    I'm having this problem of multiple draw call when using the same atlas and material.
    I suppose this is a problem related to the animator.

    I've made a few copies of a character with the new 2d animation system, changing sprites + moving, scaling, rotating them. (My character is composed by a series of sprites, something like the tutorial but with more hierarchy inside the character)
    Each copy is giving me 8 draw calls, although all sprites are at the same texture.

    Am I missing something??
     
  19. marceloSpiezzi

    marceloSpiezzi

    Joined:
    Nov 12, 2012
    Posts:
    6
    I solved this issue, it was not related to the animator.
    My problem was I was using an -1 scaled sprite for the arms. I've researched and saw that this change in scale breaks the batcher.

    I'll leave both posts here if someone gets the same problem already know something to start with =)
     
  20. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,549
  21. Gamer_Woods

    Gamer_Woods

    Joined:
    Jan 31, 2013
    Posts:
    33
  22. Gamer_Woods

    Gamer_Woods

    Joined:
    Jan 31, 2013
    Posts:
    33
    Yes, I encountered this issue, and I experimented a bit on this.

    I have a sprite sheets with 5 frames, and they are s0, s1, s2, s3, s4, (in sequence as displayed in the Project window).
    At first, I set all of them scale to (1, 1, 1), and the draw call is 1, saved by batching 4
    Second, I set s0's scale to (-1, 1, 1), and the draw call is 2, saved by batching 3
    Third, I set s0 back to default and set s1 to (-1, 1, 1), and the draw call is 3, saved by batching 2
    Forth, I set s0 to (-1, 1, 1) again, and keep s1 as (-1, 1, 1), and the draw call is 2, saved by batching 3
    Finally, I set s0, s2, s4 (1, 1, 1), and s1, s3 to (-1, 1, 1), which results in draw call 5, saved by batching 0

    NOTE: if we replace -1 with any positive number, they are all batched.

    So I think Unity's batching works like this, loop through the sprite sheet for frames (in the sequence you see in the Project window), and batch frames that have the positive/negative scale together, and continue to loop and batch those whose scale have negative/positive number, and continue to batch in this way.
     
  23. Hofik

    Hofik

    Joined:
    Feb 20, 2014
    Posts:
    4
    Hey. I have a problem when the texture atlases greater than 1024x1024 such as 2048x2048 so I drawcalls counted more than one. I have a texture in the 3 sprites and still counting 3 drawcalls. When switching to 1024x1024 is drawcalls one on one texture which is correct. You do not know what the problem is?