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.

HDRP, Lit Shader Mask Map, how to create this mask?

Discussion in 'High Definition Render Pipeline' started by NotGoodEnoughh, May 20, 2018.

  1. NotGoodEnoughh

    NotGoodEnoughh

    Joined:
    Feb 1, 2018
    Posts:
    35
    Hi, how i can to create a mask map?
    I know, that Mask map is:
    • Red channel: Metallic mask. 0 = not metallic, 1 = metallic.

    • Green channel: Ambient occlusion.

    • Blue channel: Detail map mask.

    • Alpha channel: Smoothness.
    but how can i do it without photoshop?
     
    exe2k and Gekigengar like this.
  2. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
  3. NotGoodEnoughh

    NotGoodEnoughh

    Joined:
    Feb 1, 2018
    Posts:
    35
    Thanks you so much!
     
  4. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Very nice, thanks for that!

    But anything official from Unity?
     
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    No, and there won't be unless Unity decides to allocate time. Instead you will pack them using substance, or art package or utility as above OR just use shader graph to route the channels of interest.

    I recall Unity talking about various options for this but I don't think anything concrete came of it.
     
    Cascho01 likes this.
  6. jimmyrimz

    jimmyrimz

    Joined:
    Aug 2, 2015
    Posts:
    1
  7. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,357
    Just a word of caution, I briefly tried that tool some time ago and it for some reason did not pack anything in alpha channel.

    Alloy (now free) also has channel packing tool but haven't really tested how it works.
     
  8. unity_w1ll-w065355jg

    unity_w1ll-w065355jg

    Joined:
    Feb 10, 2019
    Posts:
    4

    excuse me, I downloded this tool but.... where I have to put to open in Unity?
     
    ivagunj likes this.
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
  10. unity_w1ll-w065355jg

    unity_w1ll-w065355jg

    Joined:
    Feb 10, 2019
    Posts:
    4
  11. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Look in the menus I guess. I don't use it, but mostly this stuff works like that. Just explore.
     
  12. unity_w1ll-w065355jg

    unity_w1ll-w065355jg

    Joined:
    Feb 10, 2019
    Posts:
    4
    Excuse me, can I ask you how I can do to open it in Unity?
     
  13. unity_w1ll-w065355jg

    unity_w1ll-w065355jg

    Joined:
    Feb 10, 2019
    Posts:
    4
    I found it!! Is in Windows> Channel Packer.
     
    ivagunj likes this.
  14. ivagunj

    ivagunj

    Joined:
    Nov 2, 2018
    Posts:
    1
    In posted .gif is not visible which map is used in each channel selection. Can someone please explain the procedure of creating a mask map?
     
    tonimarquez84 likes this.
  15. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    realy cool thank's
     
  16. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,482
  17. Luuke

    Luuke

    Joined:
    Jan 18, 2017
    Posts:
    13
    Hello guys,
    I noticed this thread is some months old but I used gimp for that and it works pretty convenient. Just wanted to share it here.
    I used it for terrain layer mask map (https://docs.unity3d.com/Manual/class-TerrainLayer.html) with RGBA beeing metallic, AO, height and smoothness (in that order).
    If you have all your grayscale layers open in gimp, you have to do Image->Mode->Grayscale, otherwise the composition wont work. Then go to Colors->Components->Compose and select the right layer for each channel. Thats it!
    In my case I had a roughness map instead of smoothness so I simply inverted the grayscale layer.
     
    PutridEx and hippocoder like this.
  18. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Note: with mask maps you'll want to import them with sRGB unticked or will get incorrect rendering. And don't forget that .a is never imported as sRGB, it's not corrected (in case packing say, smoothness into albedo .a), so you can rely on alpha being imported as linear.
     
    Dave_Bowman and Luuke like this.
  19. vladibo

    vladibo

    Joined:
    Jan 29, 2013
    Posts:
    37
  20. exe2k

    exe2k

    Joined:
    Oct 26, 2015
    Posts:
    62
    is anything changed in 2022?) Or do we still have to pack mask map without official tools?
     
  21. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,357
  22. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    481
    You've got a few options for a mask If you already have the single value masks.
    ie occlusion, metallic, roughness, (detail mask)

    You can just load it into a standard shader in HDRP and then run the HDRP wizard converter.
    This will generate a Linear Mask Map.

    This has been around since 2019.3


    For an official from unity (internal) paid version, you can also use Art Engine for more custom internal channel packing, or of course any external DCC with channel packing for layer-based or node based on the market.

    Overall it depends on what you're trying to pack for customization reasons, but for mask maps in particular it's been there for some time.
     
    Last edited: Jan 9, 2022
    Camilov likes this.
  23. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,357
    If you go for graph based things, there's also Mixture (altho I dunno if it has save to texture functionality built-in): https://github.com/alelievr/Mixture

    At this point though, would be just easier to use some 3rd party packing thing.
     
  24. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    why did they do it like this in hdrp? How can it be useful to do it like this instead of separated? i need to know
     
  25. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Because Unity works in Mysterious Ways.
     
  26. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    jajaja no i really need to know, because i'm working with quixel mixer, so, do i need to create my own shader with those properties exposed or there is something useful i'm missing with the lit shader workflow?
    Creating my own shader is a waste of time, also in mixer i can not find any way to "pack" the maps inside one file... so... i need/want to know
     
  27. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    691
    Click the advanced texture setup in Quixel Mixer.
    You can assign maps to specific color channels.
    upload_2022-5-25_2-17-45.png
    upload_2022-5-25_2-17-50.png
     
  28. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    Oh thanks, i'm so dumb... now sorry but can you help me a little with something? if i use the lit shader and move the smoothness value to 0.6 it looks cool, like mixer but i create a shader with smoothness values exposed for textures and a float for value (with multiply node) and it does not look the same as the lit shader, am i missing something else? smoothness values use vector3?
     

    Attached Files:

    • fsd.jpg
      fsd.jpg
      File size:
      239.2 KB
      Views:
      168
    • asd.jpg
      asd.jpg
      File size:
      199.9 KB
      Views:
      172
  29. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    691
    You need to show me your shader and export settings before I can evaluate anything.

    I presume it might be because you confused Gloss/Roughness/Smoothness map, they are different. (Inverted?)
    Or maybe your shader does not pull from the right channel of the map.
     
    Last edited: May 27, 2022
  30. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    574
    It is usefull because it requires only one sample of texture to have the 4 informations.
    Turns out that this packing existed since the introduction of the Standard shader, where if you look at the tooltip for metallic and ao you'll see this :
    Metallic (R) and Smoothness (A)
    and
    Occlusion (G)
    .
    Is is the same packing as the one used in HDRP, with the addition of the detail mask in the blue channel.
     
    Genebris likes this.
  31. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    Yeah i figured out minutes after asking that, it makes sense.

    Thanks, but no, it is not that case. The lit shader from unity does not have a slider to change the gloss property, is the smoothness in both cases (lit shader and my shader) or at least i do not see any gloss property to change :(
    Now, my shader is very basic, it is just some nodes to expose those properties, like the smoothness. it has a float node and a texture 2d node united by a multiply node that is conected to the smoothness. In the screeshots you can see:
    The first one: the unity's lit shader and the smothness property i'm talking
    The second one: my shader with the nodes that i used to expose the (what i think is) smoothness.
     

    Attached Files:

    • 1u.jpg
      1u.jpg
      File size:
      76.1 KB
      Views:
      174
    • 2u.jpg
      2u.jpg
      File size:
      97.7 KB
      Views:
      169
  32. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    691
    Show me your export setting on Quixel Mixer as well.
     
  33. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    no wait hahaha you do not understand, the mixer thing is done i have no problem with that xD i'm talking about other thing, i was trying to make a shader with with the smoothness value exposed but in my shader the smoothness is not working the same as smoothness in the unity lit shader, is not an important thing either.
     
  34. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    481

    I wanted to clarify here for folks that there are many names from different software workflows and naming conventions that generally can mix people up a bit for texture workflows, especially when mixing older terms with newer terms

    but in general just so you're aware.

    Similar to Direct X and Open GL ( y/green channel flip) on a normal



    typically the main PBR workflow you have
    [Glossiness and Roughness]
    0 - 1
    Black Smooth

    White Rough
    respectively
    This is a "Roughness" workflow


    in Unity there is a naming collective "smoothness" and an invert of Black & White going on to adhere

    Unity naming =Smoothness
    [Roughness and Glossiness]
    0 - 1
    Black Rough
    White Smooth
    respectively
    This is a "Glossiness" workflow

    notice how it's just an invert

    Hope this helps someone somewhere.
     
    mmcveigh33 and PutridEx like this.
  35. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,861
    But why can't this be done at build time? And you haven't provided a tool to do it in all these years. (Option 1, Option 2). And what happens when you don't have a detail mask, etc, yet?

    Do I have to use shader graph?
     
    Last edited: Oct 28, 2022
    PutridEx likes this.
  36. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    574
    I'm not in charge of the roadmap and the work organisation, even if such tool included in Unity would be usefull, it is probably more a "low hanging fruit" than something else.

    If you don't have a detail mask, you can just leave the blue channel at 1 ("white") on the whole texture.
     
  37. PutridEx

    PutridEx

    Joined:
    Feb 3, 2021
    Posts:
    1,099
    I am quite annoyed by this to be honest, every time I want to use a roughness texture, I go over to shader graph.
    Currently I do AO/Height by creating a standard material and upgrading it to HDRP, if I want to use lit.

    For some reason unity does smoothness unlike literally everyone else lol, and I really don't want to go use an external program for every roughness texture I have, so I just do it in Shader graph, quite frustrating.

    A tool to create a mask map with the option to invert roughness texture would indeed be a nice addition.
     
  38. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    609
    Edit: NVM, was posted on top already.....
     
    Last edited: Nov 9, 2022
  39. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    574
    @PutridEx Maybe not exactly what you want, but the texture importer has a swizzle field in recent versions to invert and mix the texture channels :
    upload_2022-11-9_14-50-46.png
     
  40. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    481
    @PutridEx +1 for the new importer Remy mentions.

    Also if you're dealing with standard workflow textures


    Base colour
    Normal

    Metallic
    Ao
    Roughness
    Height
    (I don't remember if height gets packed in the
    Mask, probably not)

    You can use the the HDRP wizard material update option in the windows or edit menus

    With those textures loaded in a standard shader it'll auto upgrade to HDRP lit.

    You can do all in project, selected or individual.

    EDIT: my apologies for not fully reading your post
     
  41. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    60
    I'm working on a ScriptedImporter that allows you to repack texture channels however you want. Also allows you to automatically make materials and terrain layers out of a folder of texture maps. Thinking of open sourcing it. If anyone is working on a similar thing, maybe we can collaborate?
     
    nehvaleem and impheris like this.
  42. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    994
    sound useful
     
  43. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    60
    I've pushed an initial version of my tool, Swizzler (forked from unity-texture-packer). Please try it and let me know if you have any issues or feature requests! Opening issues or discussions on GitHub is the easiest way. https://github.com/wilg/swizzler
     
    jRocket, impheris and PutridEx like this.
  44. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    636
    Gold - pure gold.
     
    HIBIKI_entertainment likes this.