Search Unity

Sprite Atlas Mip Map bias

Discussion in '2D' started by mendo, Mar 2, 2018.

  1. mendo

    mendo

    Joined:
    Apr 7, 2013
    Posts:
    7
    Hello!
    We used to work with TexturePacker and recenty we started using the new sprite atlas (2017.2).

    Since we play a lot with zooms, being able to set the te mipmap bias allowed us to avoid blurry sprites with closer zooms, which worked well when the texture came from TexturePacker as we were able to achieve that using a PostProcessTexture. Now we're wondering if it's possible to set the mipmap bias on the resulting atlas texture, since we don't have access to it when it's Unity who handles it...

    Thanks!
     
  2. acuevas

    acuevas

    Joined:
    Apr 30, 2015
    Posts:
    1
    Yes please!
    It would be great to set the Bias for the atlases.
     
    _eternal and esimionescu like this.
  3. _eternal

    _eternal

    Joined:
    Nov 25, 2014
    Posts:
    304
    Did anyone find a solution to this? Same issue here. I normally use some code I found on the forums to set the mipmap bias before importing, like
    Code (CSharp):
    1.         selection = Selection.GetFiltered(typeof(Texture2D), SelectionMode.DeepAssets);
    2.  
    3.         if (selection.Length > 0)
    4.         {
    5.             foreach (Texture texture in selection)
    6.             {
    7.                 string path = AssetDatabase.GetAssetPath(texture);
    8.                 (AssetImporter.GetAtPath(path) as TextureImporter).mipMapBias = bias;
    9.                 AssetDatabase.ImportAsset(path);
    10.             }
    11.         }
    But that doesn't seem to work for Sprite Atlas objects, because I suppose the atlas is technically not a texture.
     
  4. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    205
    I've been playing around with this for a while now and cannot find a way to manipulate the mipmap bias for the Sprite atlas. If I change the texture's mipmap bias via the importer during runtime, I just de-couple it from the Sprite Atlas.

    I understand that it's a niche thing, but it would be great to have! My setup would be so damn performant if this was possible. Now I have to suffer a slight reduction in quality, which my perfectionist brain cannot accept.
     
  5. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    205
    Looks like this thread has a method of doing it - but it involves setting the bias manually at runtime. That's fine, but it could be done easier for us developers.

    https://forum.unity.com/threads/cha...ses-at-runtime-bad-idea.1298256/#post-8221338

    The method used in the code the OP wrote in the beginning does work. You have to specifically go into the SpriteAtlas and get the texture through GetSprite(s), and THEN change the mipmap bias. Doing it directly or doing it through an importer does not work.