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

The mask map in the "Lit" material

Discussion in 'Graphics Experimental Previews' started by Haugkall, Jul 12, 2019.

  1. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    These are the instructions for this map:

    Red channel: Metallic mask. 0 = not metallic, 1 = metallic.
    Green channel: Ambient occlusion.
    Blue channel: Detail map mask.
    Alpha channel: Smoothness.

    What if you are not using metal, ambient occlusion or a detail map? Just making those channels black seem to not work. Making them white doesn't work either. I just want a slot to put my roughness, gloss or I guess smoothness map in. How would I disable those other channels and only have an alpha channel affect the roughness?
     
    oleg_v and AntonioModer like this.
  2. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    Ok so after some searching, which I shouldn't have to do unity...I found this plugin for unity which packs maps. Something I didn't manage to do in photoshop. If you only want the map to have a roughness channel you just drag the roughness map into the alpha channel and save it.

    Oh and to install it you have to put the files that is in the assets folder inside the project's asset folder. You can ignore the other files you downloaded. This is the kind of stuff unity shouldn't force a user to have to go through. Just separate boxes for the texture maps you got please. ;)

    https://github.com/andydbc/unity-texture-packer
     
    oleg_v likes this.
  3. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    I just wanted to chime in and say that this user clearly does nit know what he is talking about and should not be listened to.
     
  4. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    649
    To be fair, hes on target that Unity should provide a built in way to combine multiple textures into a single RGBA texture ;). Even Alloy provided that way back in the day. So this post actually was useful to me for that link.

    Giving credit where credit is due :).
     
  5. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    It seems that the plugin that combines maps don't work properly though, the alpha channel. (Roughness) So none of the materials got the proper roughness. Does anyone know the best way to combining maps, I've been looking for a way to do this for hours and have yet to find something.

    Quite frustrating having all the maps but nowhere to put them because unity wants you to combine them which isn't possible.
     
  6. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    You can use Gimp (Free), Photoshop, Krita(Free), Substance Painter or Substance Designer to combine the maps.

    Whichever one you choose to use just look into channel packing for that software.

    Substance Painter setup
    https://forum.unity.com/threads/hd-render-materials-set-up-questions.516933/#post-3457824
     
  7. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    I got photoshop and tried pasting the maps into the channel outputs. By default it hasn't got an alpha channel, if you add it and paste another map into that channel and try to export it. Well you can't export it as png, only tiff it seems which increases the size of the texture by 10. I have tried google how to do it and there's only tutorials on how to pack RGB maps not RGBA maps, Do you know how to do this in photoshop?

    Must say though, even if you can do it in photoshop. Not looking forward to manually copying and pasting hundreds of maps into individual textures. It's really crazy that unity insist on us combining maps.
     
  8. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    You have to use RGBA unless you create a custom shader with shader graph you will have to use the default Lit shaders and the Mask map for that used RGBA

    R - Metallic
    G - AO
    B - Detail Mask
    A - Gloss/Smoothness/Inverted Roughness

    Export it as a TGA 24 bit or save the file as PSD and use it in Unity. Remember file size of the map isn't the same size it will be once loaded onto the GPU or after the texture is compiled into a build after compression.

    Your best bet is to create your own shaders with shader graph and not have to deal with packing (The reason why the map is packed is to save texture memory and performance. It's optimized for the best performance) If performance isn't what you are going for then Shader Graph is the way to go.
     
  9. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    If you only got 2 maps, metallic and roughness maps. And you don't need an ambient or detail map, would you color those channels black or white. Or maybe remove them?
     
    Last edited: Jul 20, 2019
  10. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    Set Ambient to white and you can leave detail at black. You can't delete the channels so you have to set it to something. The way ambient occlusion works is, the darker the pixel the more ambient occlusion is applied, and the lighter it is the less is applied. So setting it to white won't add any form of ambient occlusion/darken the whole model when you apply the texture.
     
  11. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    Ok thanks a lot, I suppose they expect you to modify the smoothness remapping slider because my cauldron looks like glass with the map I exported. Anyway cheers so anyone else stumbling upon this thread in the future.

    To create a mask map:
    •Grab your textures and open them up in photoshop or GIMP.
    •If you're not using an ambient occlusion or detail map you can leave ambient occlusion (Green channel) white. And the detail channel you leave black.
    •The red channel is metallic and the alpha channel which you're going to have to add by clicking the small button at the bottom of your layer window. That channel is for your roughness map, if it is a roughness map you're going to have to invert it. If it's a gloss map you can leave it as it is.
    •Export the texture in the TGA format, 24 bit.

    EDIT: I found out the hard way that you need to save it as 32bit not 24 bit. The 24 bit won't save the alpha channel.
     
    Last edited: Jul 20, 2019
  12. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    4 hours later...hello again, I have messed around with these textures for 4 hours now. And it seems when you export the TGA texture the alpha channel isn't saved even if you check the export alpha layers option. If you open the TGA file up again in photoshop the alpha channel is still there. But unchecked. I can't seem to export the alpha channel from photoshop with the TGA format. If I export it as 24bit then the alpha channel isn't saved or stored at all. Who the hell thought it a good idea to combine maps in a mask map, screw that guy!

    EDIT: Or maybe you do export the alpha channel you just can't preview it or see it in the image? Because just the RGB channels makes the picture green, the added alpha channel makes it orange. But there's no orange in the texture when you export it. Nor in the layer's preview square.
     
    Last edited: Jul 20, 2019
  13. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    The Alpha should show up. Try using just the PSD file, Unity can read it so just import the PSD file and see.
     
  14. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33

    Same with PSD, trying to export it with alpha seems to only export the RGB channels. The Alpha channel is still there in the TGA file unchecked when you open it up in photoshop after having exported it once. It seems like it's just not enabled in the preview of the texture inside of unity. It's very strange, if it's not something I've done wrong then maybe photoshop is just outdated or something.
     
  15. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    789
    It imported with the alpha channel.
    upload_2019-7-20_16-43-24.png
    Did you add the texture to the material and saw that it wasn't working? If you select the A there you should see your alpha channel and applying it to the material should work.
     
  16. Haugkall

    Haugkall

    Joined:
    Jan 25, 2018
    Posts:
    33
    I found this post from a guy on the internet.
    Maybe the tga file is exported with alpha you just can't see it in the preview inside of unity just like you can't see it in the preview inside of photoshop. In which case you're right and it probably does affect the material if I put it on there.
     
  17. akshats429

    akshats429

    Joined:
    Sep 21, 2019
    Posts:
    1
    hey bruh how's it goin....I just wanted to ask that I have download some textures form a website and I am using HDRP's lit shader in unity...but the problem is ...those textuer did not include the metallic map to create a mask map in photoshop...also niether the smootheness map...so what should I do in the situation...please help
     
  18. AntonioModer

    AntonioModer

    Joined:
    Jul 29, 2014
    Posts:
    65
    i do this, when i need only smoothness:
    red to black (0), green to white(1), blue to white(1), smoothness to my texture.
    You need make green to 1, because if make 0, material will not receive light !
     
  19. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    If I only needed smoothness and I wouldn't need alpha channel for the main texture, I'd just put the smoothness map to main texture alpha and make a shader graph that maps these accordingly. You save extra sampler by doing so and get rid of one extra texture.

    Mainly saying this aloud as OP seemed to somehow think there's no other way. Default shaders use a sensible setup for PBR rendering but you may not always have use case that requires all those maps. In latter cases you are always free to roll out your own shaders using Shader Graph.
     
  20. Mariusz-Born7

    Mariusz-Born7

    Joined:
    Sep 4, 2015
    Posts:
    40
    In Gimp there is a simple way to create mask map. Prepare gray images (separate images or layers) and next use Colors->Components->Compose, select RGBA source images and confirm. You will have a new image created which you can save as a png. Import it into Unity and disable sRGB.

    gimp.jpg mask_map.jpg
     
  21. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    515
    I'm not sure if its already shown in another forum post or if its relevant but here is the LitMask ShaderGraph i made to support the mask texture.

    Defaults
    BaseColor default color is white
    EmissionColor default color is black mode is HDR
    NormalStrength default is 1
    AOStrength default is 1
    Metallicness default is 0
    Tiling default is [1,1]


    upload_2023-10-27_13-13-7.png