Search Unity

Sprite Atlases

Discussion in '2D' started by Deleted User, Jun 1, 2021.

  1. Deleted User

    Deleted User

    Guest

    I'm currently trying to understand how to use sprite atlases, especially for now, what to pack in it, and I'd like advice about what I did.

    I created the sprite atlas below:

    Capture d’écran_2021-06-01_21-49-25.jpg
    1. I set "Max Texture Size" to 1024 because my biggest sprites are 1024x1024,
    2. in "Objects for Packing" I dragged entire folders instead of sprites themselves; it seemed something to do,
    3. the three folders (mobilier, murs and plateformes) contain actual sprites, psd files.
    So, my questions are: if I add new art to the folders that contain psd files, will the atlas update itself automatically? are my settings okay?

    When I enter play mode, I can notice that the fps and the ms count are a lot better, + around 30/40 fps and around 6/7 ms.

    Thanks for your advice! :)
     
    Last edited by a moderator: Jun 1, 2021
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    It will update the atlas when you add new art into those folders, its the easiest way to add new art to the atlas.

    For your settings you want to set a max texture size that will encompass all your sprites into one texture or as many as you can. The less textures you have the less draw calls you have. That setting is for the atlas texture(s) and not the sprites.
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    Thank you. :)

    So, if I understand correctly, an atlas that has a maximum size of 4096 should contain 16 1024x1024 sprites with a padding of 0?
     
    Last edited by a moderator: Jun 2, 2021
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    That is the theory. If the sprites have transparency and don't take up the whole 1024x1024 it may fit more with tight packing and or allow rotation enabled.
     
    Deleted User likes this.
  5. Deleted User

    Deleted User

    Guest

    Maybe I don't know how to use sprite atlases but it appears that using them removes the normal maps...

    Game view in play mode:

    - without atlases:

    Capture d’écran_2021-06-09_09-03-44.jpg

    - with atlases:

    Capture d’écran_2021-06-09_08-45-27.jpg
     
  6. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    This to me is an oversight on Unity's part. You need to create your own custom atlases.

    Due to the nature of how normal maps work, they need to occupy the same texture space as the sprite. This means that if the sprite is at 32,32 on the sprite atlas, the normal map for that sprite needs to be at 32,32 on the normal map atlas.

    With a SpriteAtlas it automates the positioning of the sprites so the position on the texture is not guaranteed to be the same on both the color and normal map atlases.

    What Unity needs to do is make a normal map option for the sprite atlases, this way you can have a sprite named wall and then name the normal map for it wall_n and it will use the color atlas position of the sprite to position the normal map sprite.
     
    Deleted User likes this.
  7. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    SpriteAtlas now supports additional/secondary maps for Sprites. You can specify secondary textures in the SpriteEditor and SpriteAtlas should automatically generate Normal Map Atlas. Please make sure the position of the Sprite and its Normal Map is the same as well as the Texture Size are the same in the source Assets .

    https://docs.unity3d.com/Manual/SpriteEditor-SecondaryTextures.html
     
    Deleted User likes this.
  8. Deleted User

    Deleted User

    Guest

    Yeah, that's what I already do.

    Both the bump and normal maps are in the same folder that contains the sprite, they are added to the sprite. What I did is creating the atlas by dragging the folder that contains both the sprites and their secondary textures, but, as you see on the image, they do not display in play mode.

    The sprite atlases all look like this one:

    Capture d’écran_2021-06-09_14-25-15.jpg Capture d’écran_2021-06-09_15-14-40.jpg Capture d’écran_2021-06-09_15-15-05.jpg
     
    Last edited by a moderator: Jun 9, 2021
  9. Deleted User

    Deleted User

    Guest

    It's a bug in the editor. I just got the atlases using the secondary textures when I tested a new object and the normal maps worked. It never happened again though. :(

    Here it is:

    Capture d’écran_2021-06-11_16-30-22.jpg

     
    Last edited by a moderator: Jun 11, 2021
    Venkify likes this.