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

Atlas sprites bleed when sliced in one axis

Discussion in 'UGUI & TextMesh Pro' started by NeilW, Feb 28, 2017.

  1. NeilW

    NeilW

    Joined:
    May 29, 2014
    Posts:
    40
    Hi - I have come across this issue a number of times and have always hacked around it but was wondering if there is a proper solution or if this is a bug in unity. Basically if i have an atlased sprite that I want to slice horizontally (i.e. the top and bottom borders are set to 0 in the sprite editor) and it has some empty space above or below it in the source image. I end up with the sprite above or below in the atlas bleeding into this empty space:

    SpriteBleed.png

    If I change the image type to simple the problem goes away.
    If I add vertical slicing by setting a top border that excludes the empty space the problem goes away.

    I know that when the sprites are packed onto the atlas the empty space is removed and presumably something is done at run time to account for this, it seems like there is a bug in this accounting in this situation.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @NeilW

    That's interesting, I've never used / needed atlas maps so far...

    So if you frame your door / panel tightly, then everything is OK? If this is the case, seems like atlas packing does not notice empty space that you want to have in your panel, but instead of this, it just creates tightly framed bounding box around your art and uses it to pack your art to texture sheet... yet it then uses the bbox you made for UVs / rendering...
     
  3. NeilW

    NeilW

    Joined:
    May 29, 2014
    Posts:
    40
    Yep that is correct and this is very nice behaviour in many cases for example if we have a layered bit of UI then an artist can just export the layers with empty space around them, then in game they are very easy to layout in the correct relative positions because they are the same size, but internally unity will only be drawing quads of the same size as the area that has content so you don't waste any fill rate.
    I don't know if unity also does this with non-atlased sprites but I don't see why not (the bleeding obviously wouldn't be an issue here)
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,294
    For those landing here via search:
    - Include small border from bleeding side while slicing / in sprite editor.
    - Set sprite atlas padding to at least 4px, and disable tight packing / allow rotation.

    Doing so fixed same issue for me.