Search Unity

RMA texture to Unity PBR

Discussion in 'General Discussion' started by AndersMalmgren, Sep 23, 2019.

Thread Status:
Not open for further replies.
  1. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Hey guys. I bought a few models from Dekogon on cgtrader for my new unity scene. They have combined 3 maps into one

    RMA (Red Channel - Roughness | Green Channel - Metallic | Blue Channel - Ambient Occlusion)

    Any tool I can use or do I need to separate manually in some tool like Photoshop?

    Pretty sure I need to invert Roughness too since Unity uses smoothness
     
  2. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I'm not sure I did it right. Look at the wood. It is as shiny as the metal screw :D

    gloss.jpg

    I pasted the Green channel into the gray channel of a new image. I then pasted the Red channel into a seperate image and inverted it. THen I pasted it as alpha channel.
     
  3. MrArcher

    MrArcher

    Joined:
    Feb 27, 2014
    Posts:
    106
    For the appearance of the wood I'd say to check two things:
    1. Did the alpha channel definitely come through in the export? You should be able to see it in the inspector (just above the preview window) and be able to toggle between r,g,b and a channels. Photoshop doesn't always export the channel if it's not a valid format. What filetype were you using (.tga, .png)?
    2. Is the new metal texture being imported with sRGB disabled? Otherwise the engine will be converting it from linear to gamma space. In general (assuming you're in linear colour space), you want your albedo and diffuse to be sRGB enabled, with all other maps (AO, MetalGloss, Spec etc) disabled.
    On the question of whether there's a tool for that, it's relatively simple code to create an editor tool or standalone app for it. GetPxels() and SetPixels() with some channel manipulation and file IO. Some googling turned up this plugin for unity. Alternatively (if you've got a lot of files to process), Photoshop's Actions (Window > Actions) should be sufficient for recording and repeating an operation, and then batch-running it on a destination folder
     
    AndersMalmgren likes this.
  4. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Sorry forgot to answer here. I was dumb, I saved it as tga since original was tga and the alpha channel is lost. :)

    It looks better now, still not sure it's completly correct. But what I did was invert roughness channel and instertes it as alpha on the metalness map.

    Edit: Will check the other stuff tonight, good points
     
  5. MrArcher

    MrArcher

    Joined:
    Feb 27, 2014
    Posts:
    106
    Yeah there's a checkbox when you're saving tga files to enable saving Alpha Channels, it's easy to miss! If that still doesn't work you may need to convert the image mode to RGB (instead of greyscale). This should make sure it gets saved as 32bit RGBA.
     
  6. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I had so save it as png, couldnt get it to save alpha for tga in Photoshop. Oh well, probably did something wrong. But I did made sure it was in RGB mode and saved as sRGB. edit: maybe I used the wrong pixel depth. Will try again
     
  7. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  8. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Allright so I finally got alpha working with tga, I do not know what I did wrong yesterday. Seems photoshop is picky about it. Interesting enough, when opening the tga again in photoshop it looks different from when I saved it, and also different from when I open my .png equivalent. Here is how the tga looks when reopened in photoshop after save. you can see the alpha is there, but its not transparent in the view

    upload_2019-9-24_17-11-18.png

    And same thing for my png looks like this
    upload_2019-9-24_17-12-50.png

    I guess tga saves more layer info somehow? It also looks different inside Unity

    upload_2019-9-24_17-14-16.png

    On the left png, on the right tga

    And finally slightly different on the actual material (here with sRGB on both)

    Here is png
    upload_2019-9-24_17-16-14.png
    And here is tga, again both sRGB on all maps
    upload_2019-9-24_17-16-36.png
     
  9. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Here is tga metalness with sRGB disabled for NRM, M and AO (NRM did not have the option).
    linear.png
     
  10. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I dont know if it makes me any wiser :p Bigbest change I think with sRGB off are on the AO
    sRGB on

    upload_2019-9-24_17-22-45.png

    Off (looks a bit flatter?)
    upload_2019-9-24_17-23-18.png
     
  11. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I've always wondered this also. All maps should generally be output in linear, but this isn't always the case.

    I believe that if you edit a texture in photoshop or whatever, it will not be aware of linear or srgb and will simply present the colors stored in each pixel. This will generally look wrong to viewer if its linear (with albedo), since it will present it as if it were srgb. If you're dealing with greyscale maps though, I don't believe there is any way to realistically tell.

    I could be wrong about this, hopefully someone who works more on the art side can add clarity.

    And if there is some way to tell the difference other than just trying srgb/linear and picking the one you think kinda looks more correct, I'd love to hear it.
     
    AndersMalmgren likes this.
  12. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Everything went well until I hit this pile of sand bags.

    Its way too metalic with my new tga

    upload_2019-9-24_18-14-40.png

    With the png I produced yesterday
    upload_2019-9-24_18-15-6.png

    I tried doing twice. Same result. Let me walk you through it and you guys can maybe tell me what I do wrong
     
  13. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I made a little clip, I do not understand what I am doing wrong :D At the end I show the difference between the png from yesterday and my targa from today

     
  14. frosted

    frosted

    Joined:
    Jan 17, 2014
    Posts:
    4,044
    I donno enough about working with maps in photoshop to help. Hopefully a proper artist will chime in soon.
     
    AndersMalmgren likes this.
  15. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Just realized it failed to capture my mouse in shadowplay, here with mouse and mic capture in OBS

     
  16. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,157
    Have to admit I'm surprised no one suggested a custom shader. If I remember correctly you said you weren't on the new HDRP but do you have Amplify Shaders or ShaderForge? You could split the different channels directly into the different fields of the output.
     
    Martin_H likes this.
  17. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    I would like to stick on the Standard built in shader if possible.
     
  18. MrArcher

    MrArcher

    Joined:
    Feb 27, 2014
    Posts:
    106
    In the above video, it looks like you're applying the glossiness as a mask to the metal in addition to having it as an alpha channel. This'll result in high-transparency and thus the metalness will head towards white (so much more metallic). The stage you had it at about 0:38 is where you want to save it. And again, you don't want sRGB on any of your maps except colour.

    In .png files, alpha acts as transparency in photoshop, but this isn't the case for .tga files. This is because of a decision made by adobe:
    The important thing is the data in the textures themselves, not how photoshop chooses to display it. You're only seeing the solid colour in .tga files because adobe thought it would lead to less confusion to let users manipulate the channels seperately. For .png files, as they're commonly used for web graphics with transparency, Adobe decided that the file would open with the alpha applied as a transparency mask.

    In either case, the colour and alpha channels of the map itself are the same.
     
    Max-om, AcidArrow and AndersMalmgren like this.
  19. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    When I didnt get it to work i followed a guide that did it like that. But I think the problem was bit depth, so will try again. Thanks, will let you know tonight
     
  20. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Thanks for the tips. Now I'm pretty confident I have the look the artist intended.
     
    Max-om and MrArcher like this.
  21. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    @AndersMalmgren https://github.com/andydbc/unity-texture-packer

    That may be useful to you in the future :) Useful for packing channels, unpacking channels etc without having to dive back into photoshop. I also find it often eliminates the need for a custom shader as you can just repack using the channel structure required by the shader in question :D

    I like it because I can pull out the channels from any texture, and combine channel data from all sorts of sources into a single map when required :) Its also useful for quickly isolating and testing a channels data within unity without having to re-export.
     
  22. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    @MrArcher did link that, I had a quick look, but it seemed it could only pack to multi channel. If they support from multi channel they need to update their github page, because their animated gif only shows that direction :D
     
  23. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    I haven't read full thread.

    For repacking textures, Photoshop is the obvious choice, but you do need to know your way around the program. And the workflow is a bit convoluted. You need to know how to make selections, work with layers, and access channels. It's a lot to explain, but thankfully there are thousands of tutorials showing this.

    What I'd recommend, however, is Substance Painter. Very easy to repack and export textures in this program. You can repack to any common format or define custom format in a few easy steps. But you gotta buy the program. But it's cheap, and at least right now you can still get non-subscription license of the full product.

    If all you need to do is change how some textures are packed, probably some scripts out there you could do it within unity with. But if you regularly need to fidget with textures and want some control to edit things, substance painter is good choice because it's very intuitive, very visual, and makes common task so trivial that even a blind programmer could make things look nice.

    If you pick up substance painter and spend maybe a week just running through tutorials texturing simple tings, you will be surprised just how much you can do even if you aren't much of an artist. I wouldn't recommend a non-artist pick up zbrush, because they wouldn't be able to do much with it without tons of practice. But the learning curve on substance painter is very small, and for that reason I think it really belongs in any developers toolbelt.
     
Thread Status:
Not open for further replies.