Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    511
    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:
    405
    Not yet. However we will be addressing this soon. Will keep this thread updated. Thanks.
     
  3. kyuskoj

    kyuskoj

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

    Le-nain

    Joined:
    Nov 26, 2012
    Posts:
    61
    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:
    330
    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:
    61
    That's good news, thanks for the update.
     
  8. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    511
    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:
    405
    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:
    4
    2020.2? so, december more or less?
     
  12. ZimM

    ZimM

    Joined:
    Dec 24, 2012
    Posts:
    957
    @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:
    405
    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:
    957
    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:
    50
    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:
    957
    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:
    50
    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:
    957
    Except there are no official, say, normal-mapped shaders for sprites, as far as I know.
     
  19. GamerXP

    GamerXP

    Joined:
    Mar 22, 2014
    Posts:
    50
    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:
    957
    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:
    50
    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:
    1,927
    Is this mean secondary texture will work with tilemap? (tilemap renderer) ?
     
  23. yuanxing_cai

    yuanxing_cai

    Unity Technologies

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

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,927
    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:
    330
    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:
    1,927
    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:
    1,927
    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:
    1,927
    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:
    330
    Yes it is.
     
    waruban likes this.
  31. Jamez0r

    Jamez0r

    Joined:
    Jul 29, 2019
    Posts:
    116
    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.
     
unityunity