Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2019.2.0b1 Secondary Textures + SpriteAtlas

Discussion in '2D Experimental Preview' started by Lo-renzo, May 11, 2019.

  1. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Will secondary textures support packing into an atlas in paralllel? For example, if I were to assign my sprites a normal as a secondary, would it be possible to generate another atlas automatically out of the secondary textures that exactly mirrors with packing of the primary textures?

    Another feature that would really be nice is being able to generate at atlas outside the Editor, like when pulling from the web on load or supporting player-made mods. Opening the atlas up a little would make it much more viable for my needs.

    Also, are 2D Lights not ready yet? I'm not seeing a specific package for it, nor a "2D Light" script as in this video, nor under any Light or 2D dropdown.
     
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Not yet. However we will be addressing this soon. Will keep this thread updated. Thanks.
     
  3. kyuskoj

    kyuskoj

    Joined:
    Aug 28, 2013
    Posts:
    56
    Is this applied on 2019.3.0?
     
    Last edited: Sep 26, 2019
  4. Le-nain

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    62
    Subscribing to the thread because I've been asking this question a couple of time already, so I want to be updated whenever it will happen
     
  5. Deimos3DA

    Deimos3DA

    Joined:
    Feb 2, 2018
    Posts:
    1
    Im also using a shader graph that uses secondary textures and need the atlas packing to be exactly the same as the main textures atlas. I would like to know if this issue has been solved.
     
  6. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    This issue is high priority on our list, we'll probably start working on this in a few weeks.
     
  7. Le-nain

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    62
    That's good news, thanks for the update.
     
  8. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,503
    Will it be possible to enable its use once already built for pulling from web or player-made mods?
     
  9. ZealotDKD

    ZealotDKD

    Joined:
    Aug 9, 2015
    Posts:
    4
    our current workflow is a bunch of seperate sprites packed into a unity atlas, then we set the sprites in an animator. will it be possible to just add identical normal map sprites, generate an identical atlas from those, and add the normal map atlas as a sub atlas? i really dont want to be re-adding 3000 sprites to a bunch of animations. doing it the first time with albedo was enough.
     
  10. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Support for secondary textures in SpriteAtlas has been added and will be available in the upcoming 2020.2 alpha (likely to be 2020.2.0a5). Will post an update once its published. Thanks.
     
    ZimM, Lo-renzo, Le-nain and 2 others like this.
  11. isbasher

    isbasher

    Joined:
    Mar 19, 2014
    Posts:
    8
    2020.2? so, december more or less?
     
  12. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    @Venkify
    If I might ask, how do secondary textures in SpriteAtlas work from a technical standpoint? Will the sprite mesh get a second set of UVs? I made a custom system for secondary textures in sprite atlases back in 2017, but it was a pretty ugly solution, so I'm wondering how the official one will work.
     
  13. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    638
    Packing SpriteAtlas will create a new atlas texture for each secondary texture associated with a sprite retaining the texture uv coordinates from the primary atlas texture.
    No, only the primary uv(0) channel data is used as texture uv coordinates are retained for the secondary atlas textures.
     
    Le-nain likes this.
  14. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    So this means that the secondary texture will be positioned in exact same position in secondary atlas as the primary texture in primary atlas? Won't that significantly reduce the efficiency of sprite packing? Let's say there are 10 sprites in the atlas, and 5 of those sprites have a secondary texture. If UVs are to stay the same, it sounds like the secondary atlas will have just those 5 sprites with secondary textures with huge empty holes between them.
     
  15. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    76
    Seems so, but if you're to make a separate atlas for that - you have to add additional UVs to sprite's meshes, and, main problem, you will need separate shaders that will use additional UV channels.
    Best thing they can make is do a toggle somewhere to switch between "same layout" and "separate layout" secondary texture packing mode, 2nd one for those who will write their own shaders
     
  16. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    If you are to use secondary textures - won't you have to write your own shaders that utilize secondary textures anyway?
     
  17. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    76
    No, they are automatically applied to the material, if there is a property with same name as secondary texture. So you can use existing shaders normally
     
  18. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    Except there are no official, say, normal-mapped shaders for sprites, as far as I know.
     
  19. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    76
    There are. Like, ones for 2D lights. Also, using standard shader for the sprites is fine as well. Default sprite shader do not write depth, so it don't work with post-processing effects like DOF
     
  20. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    963
    2D lights are not part of the default render pipeline. And standard shader is absolutely not fine for sprites - sprites need special shaders to support instancing, flipping and pixel snapping. Sprites with alpha textures can't really write meaningful depth in any case.
     
  21. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    76
    They can if you use discard to ignore transparent pixels. Well, that's not the problem here. Thing is they made it this way so it's compatible with current shaders out of the box, and I don't see problem with it. You can just pack sprites with normal maps and without them in different atlases.
     
  22. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Is this mean secondary texture will work with tilemap? (tilemap renderer) ?
     
  23. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Yes, Tilemap Renderer works with secondary textures.
     
  24. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Can you be more specific about which version of Unity it is expected to work? Because I am pretty sure I have tried it on tilemap renderer on Unity 2019.3 but it didn't work...
     
  25. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    2019.3 does have the support for secondary textures in Tilemap Renderer. Can you elaborate on how it didn't work?
     
  26. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    I am trying to use it with 2dRenderer (URP) and I am pretty sure it was not coming through... I made secondary texture and wanted to bring it through say _ReflectionAmount but it was not working as expected.

    Perhaps, the issue is to do with 2DRenderer not the secondary textures.

    Can you let us know in which Unity version and which rendering pipeline and what renderer this secondary texture works? Right now, this isn't very clear ... we have many types of renderers, rendering pipelines combinations which makes finding which combination works confusing.

    Even the official document for the secondary texture just says it only works with Sprite renderer, (and) but does not say anything about what rendering pipeline it is expected to be used with.
     
  27. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Which version of the Unity supports secondary texture with atlas? does 2019.4 supports this? Or do I have to go with 2020 ?
     
  28. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Has this ever happen?
     
  29. waruban

    waruban

    Joined:
    Oct 18, 2019
    Posts:
    2

    is it already implemented in 2020.2.0b9 version ??
     
  30. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Yes it is.
     
    waruban likes this.
  31. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    205
    Just a heads up - there is an issue that I ran into that causes Unity to crash on startup: https://forum.unity.com/threads/cra...ated-to-secondary-textures-on-atlases.996353/

    The functionality of the secondary textures works great while Unity is running, and on the PC standalone build. For now as a workaround I am removing the Sprite Atlases from the project (moving the files outside of the project folder) when I need to open the project, and then adding them back in after it is opened.
     
  32. _Exerion

    _Exerion

    Joined:
    Dec 3, 2014
    Posts:
    12
    So do normal maps work with sprite atlases now? Has anyone actually use it?
     
  33. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    It works with 2DRenderer at least.
     
  34. Kruemelkatze

    Kruemelkatze

    Joined:
    Sep 5, 2014
    Posts:
    10
    I'm currently trying to add a secondary texture to the sprites inside an atlas. When I add a _NormalMap (or any other secondary texture) to individual sprites, the atlas updates, but the region in the secondary atlas texture does not contain the sprite's secondary texture, but a distorted version of the main atlas texture.

    I'm using the Sprite Atlas v2. Should i downgrade again?
    EDIT: Also happens after switching to v1.

    Sprite Atlas v2, Unity 2021.1.1f1
     

    Attached Files:

    Last edited: May 7, 2021
  35. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Wow. Ok that definitely seems wrong... only Unity can answer this..
     
    Kruemelkatze likes this.
  36. Kruemelkatze

    Kruemelkatze

    Joined:
    Sep 5, 2014
    Posts:
    10
    Any idea or update on this? :)
     
  37. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    205
    I did not get this issue. Although I did get some issues with how the sprite atlas's normals interact with light.

    EDIT: This has now been reported as a bug in this thread
     
    Last edited: Nov 9, 2021
  38. RyhorKorneu

    RyhorKorneu

    Joined:
    May 5, 2021
    Posts:
    2
    Any chance to have the separate compression for the secondary textures atlas?
     
  39. theGreatSlutze

    theGreatSlutze

    Joined:
    Jan 7, 2013
    Posts:
    25
    Is there a description somewhere for how this should work, or what it should look like?

    I'm unable to tell where my secondary textures should be located, or what I need to do for them to be packed correctly. If I have my main and secondary texture for a sprite in a folder, and I pack the entire folder, will they be correctly atlased? Can I see the secondary atlas somehow? What will let me know that it's working correctly?
     
  40. theforgot3n1

    theforgot3n1

    Joined:
    Sep 26, 2018
    Posts:
    205
    The textures that you are packing need to have the secondary texture attached to them via the normal route in the Sprite Editor. Then the secondary textures will be automatically packed together with the main textures. You will then be able to see them in a little tab in the atlas for the preview.
     
    theGreatSlutze likes this.
  41. ptm_oo

    ptm_oo

    Joined:
    Oct 30, 2014
    Posts:
    35
    Following this 'Packing into an atlas' thread, there isn't really an answer to simple issue.

    Using atlases on other textures than _MainTex doesn't really work.. is there any solution to this for custom shaders?

    // in this example _MainTex and _TransisionTex should use unity texture atlases. But only _MainTex works.
     
  42. Foxaphantsum

    Foxaphantsum

    Joined:
    Jul 5, 2013
    Posts:
    139
    You ever solve this issue?