Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

    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,361
    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

    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

    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,500
  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

    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:
    38
  20. exe2k

    exe2k

    Joined:
    Oct 26, 2015
    Posts:
    63
    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,361
  22. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    591
    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,361
    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:
    1,589
    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

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

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,589
    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:
    724
    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
     
    Makit3D likes this.
  28. impheris

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,589
    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:
      236
    • asd.jpg
      asd.jpg
      File size:
      199.9 KB
      Views:
      238
  29. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    724
    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:
    690
    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:
    1,589
    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:
      243
    • 2u.jpg
      2u.jpg
      File size:
      97.7 KB
      Views:
      233
  32. Gekigengar

    Gekigengar

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

    impheris

    Joined:
    Dec 30, 2009
    Posts:
    1,589
    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:
    591

    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,908
    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:
    690
    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,133
    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:
    835
    Edit: NVM, was posted on top already.....
     
    Last edited: Nov 9, 2022
  39. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    690
    @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
     
    Gekigengar likes this.
  40. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    591
    @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:
    84
    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:
    1,589
    sound useful
     
  43. wilgieseler

    wilgieseler

    Joined:
    Oct 17, 2013
    Posts:
    84
    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:
    657
    Gold - pure gold.
     
    rmele09 and HIBIKI_entertainment like this.
  45. Mori_X

    Mori_X

    Joined:
    Mar 17, 2023
    Posts:
    25
    Hi master =) I just tried to get your swizzler running in latest 2022.x LTS HDRP, sadly nothing pops up when I click one of the two options in tools/

    I would badly need your tool running! Shame on unity, because your tool should be standard in unity!
     
  46. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Is this tool still the best method for creating the mask out of photoshop?
     
  47. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Do you mean just load the maps in any incorrect slots and then run the wizard? How do you run the wizard on a specific material like this? I’m a little confused I have not used the hdrp wizard very much besides setting up the project.
     
  48. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    591

    The HDRP wizard in Unity has a tool option that helps to convert materials from the Standard lit shader to the HDRP lit shader. When you run the wizard, it automatically packs the necessary maps and adjusts them to work properly HDRP, this process generates the linear mask map.

    window > Rendering > HDRP Wizard > Convert All/Selected Built-in [Lit] Materials to HDRP [Lit]
    or
    Edit Rendering > Materials > Convert All/Selected Built-in [Lit] Materials to HDRP [Lit]
    Both do the same thing.

    upload_2023-6-13_13-6-0.png

    both the wizard and edit manu have the upgrade materials option.

    In the Standard shader, certain maps are packed in specific channels of the texture:

    • Albedo texture: The alpha channel can contain smoothness information.
    • Metallic texture: The alpha channel can also contain smoothness information.
    • Normal Map texture: This should be in OpenGL format with Y+ and the swizzle function can be used to correct it if needed.
    • Height texture
    • Occlusion texture
    • Detail mask texture
    Smoothness can be represented as either a gloss map or an inverted roughness map, depending on the workflow and the source material. It is packed into either the Albedo A channel or the Metallic A channel, swizzel can also be used here if incorrect.

    In the HDRP shader, the packing and channels are different:

    • BaseColor texture
    • Mask texture (in linear colour space)
      • R channel represents Metallic
      • G channel represents Ambient Occlusion (AO)
      • B channel represents Detail Mask or Height, depending on the material
      • A channel represents smoothness
    The Normal Map should still be in the OpenGL format.

    Linear Mask map generated in action
    upload_2023-6-13_13-9-21.gif

    This feature is particularly useful if you primarily work with Unity and don't have access to texture-packing tools commonly used by artists ( DCC). It simplifies the process of upgrading materials to HDRP.

    However, if you are using custom third-party assets that have their own texture packing conventions, you may need to find a solution that works best for your specific case.

    If you don't have access to industry-standard tools like Substance, Maya, or ArtEngine, Quixel Mixer can serve as a robust alternative to Photoshop for texture packing, especially considering how Photoshop handles alpha as transparency in specific formats.

    For artists, you can pack textures following the Unity Standard packing convention, as it only requires packing one alpha channel. Later, you can use the HDRP wizard to convert the materials, this could be useful if you need to have the full library compatible with HDRP. This approach can speed up material generation and batching within Unity or your digital content creation (DCC) software.
    otherwise, you can just pack according to the pipeline.

    If you're building or using a content delivery network (CDN), I'd advise keeping the textures unpacked and create a custom packing setup during the exporting process. This way, you can cater to individual artist workflows and avoid unnecessary repacking steps.

    end result and this entire process can be done within HDRP
    upload_2023-6-13_13-33-29.png
     
    Last edited: Jun 13, 2023
    rmele09 likes this.
  49. rmele09

    rmele09

    Joined:
    Nov 8, 2010
    Posts:
    712
    Thank you for the detailed response, let me give this a go and I'll post back!
     
    HIBIKI_entertainment likes this.
  50. Makit3D

    Makit3D

    Joined:
    Oct 10, 2015
    Posts:
    4
    If anyone should come here looking at this plugin for Unity I can vouch that it still works with versions up to 2023.1.13f1. It might seem a bit cumbersome, but it is very easy to use. I have also been using it with the beta version of Muse with HDRP and Raytracing. I can no longer live a happy life without it.

    Also, I use the Channel Packer instead of the HDRP wizard because the latter doesn't always work for me.