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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

2D Sprite - Unity5 vs Unity4.6 - What's going on?

Discussion in '2D' started by HitsuSan, Mar 18, 2015.

  1. HitsuSan

    HitsuSan

    Joined:
    Sep 28, 2014
    Posts:
    145
    I don't know if this has been already explained but i couldn't find any information about so i'm just going to post an image that sums up the problem, i'd like to know what's going on especially performance wise.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,998
    See sprite importer settings (advanced).

    By default mesh type is "tight" (this used to be pro version only in 4.x)
    Can change it to "full rect" if needed.

    Tight mesh saves in overdraw, probably more useful to have in mobiles though?
     
    theANMATOR2b likes this.
  3. HitsuSan

    HitsuSan

    Joined:
    Sep 28, 2014
    Posts:
    145
    Thanks mgear! This is very weird, why the hell Full Rect is not the default sprite 2d importer?
     
  4. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    There's a performance balanced between the number of vertices pased to the renderer, and the amount of overdraw due to the meshes taking up a larger screen area. A full rect is 'worst case' for overdraw as it is the largest mesh for screen space. Overdraw is typically more expensive than the number of vertices passed, therefore Unity optimises overdraw but creating a tighter mesh around the sprite.

    This is why it's defaulted, as it is generally better for performance
     
    theANMATOR2b likes this.
  5. HitsuSan

    HitsuSan

    Joined:
    Sep 28, 2014
    Posts:
    145
    Though i've gained a significant performance boos while converting everything to full rect, that's cause i don't have too much overdraw going on?
     
  6. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    Possibly, always worth taking a look at the frame debugger to see what's going on in those kind of cases.
    Often batching is constrained by the number of vertices thrown at it, so if there are *loads* of verts you will get multiple render calls even if you're packing your textures into the same atlas of some kind.

    Overdraw is basically induced by rects that overlap, so if you don't have many overlapping sprites overdraw won't be too much of an issue. You can actualy check overdraw in a scene by hitting the Shaded mode in the Scene window (top left corner) to Miscellaneous -> overdraw.
     
    theANMATOR2b likes this.
  7. HitsuSan

    HitsuSan

    Joined:
    Sep 28, 2014
    Posts:
    145
    Thanks Newcomma, i guess i'll have to pay attention to the frame debugger much sooner than i thought! Still the automatic tight mesh generator as it is is not really much useful cause those shapes that it makes are not optimized at all, should i have to consider to make my custom shapes for each sprite?
     
  8. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    The way it makes it's tight rects are dependent on a number of factors and what the sprite looks like, it basically works on alpha cutout, so if you have 'glow' around an object, where it fades into the image then alpha becomes 0 quite far out, which means you won't get a very tight mesh around the main object. On the other hand if you have loads of alpha space in your image then it'll cut away a lot. So your mileage will vary.

    It would be nice if Unity exposed some paramter to let you adjust how tight the mesh becomes (and increases the number of verts) so it is easier to control.
     
  9. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89
    Also I've noticed in your example screenshots you have the skybox enabled in the former case, this will give you a perofrmance hit, so if you're just comparing the above it won't be a totally accurate example
     
  10. HitsuSan

    HitsuSan

    Joined:
    Sep 28, 2014
    Posts:
    145
    Yeah for sure it will be a better option to be able to choose some parameters (not that being able to make a custom planar mesh inside the editor wouldn't be great...). Oh yeah that's just how a new project looks like on Unity5, i deliberately choose to not change any parameter to be sure but i know. Still reverting everything on planar mesh on my project made me bring the performance up from 15fps to 25fps on the oldest pc i could find.
     
  11. Febtober

    Febtober

    Joined:
    Mar 19, 2015
    Posts:
    3
    I was about to make a new thread, but this is related...

    How do I change the mesh type when I'm creating Sprites using Sprite.Create??
     
  12. Newcomma

    Newcomma

    Joined:
    Feb 10, 2015
    Posts:
    89