Search Unity

PBR: Difference between Unity standard shader and what is discussed at Unite conference

Discussion in 'General Graphics' started by ArachnidAnimal, Jun 20, 2017.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,815
    (Bear with me because I'm still trying to learn PBR)

    For the Metallic mode in the standard shader, the red channel of the metallic map is for "metalness", and the alpha channel is for "roughness".

    I just watched the 2014 Unite conference, where the member of Alloy Physical Shader discusses the "Metal-Rough style". Basically he is saying the setup is:

    metalSyle.jpg

    17:14

    The blue channel is for specularity for dielectrics only.
    So with this setup then truly the metallic workflow could be used for a combination of metals and non-metals.

    So the standard shader doesn't support this style, causing metallic workflow to be avoided for non-metal materials.

    So I guess the question is could this implementation resolve issues such as these:
    https://forum.unity3d.com/threads/5-3-standard-pbs-is-wrong-cannot-eliminate-remove-specular.375339/
    https://forum.unity3d.com/threads/c...with-standard-shader-in-metallic-mode.477465/
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    That's a talk on the Unity 4 version of this asset:
    https://www.assetstore.unity3d.com/en/#!/content/11978

    It's a PBR shader framework that predates the Unity 5.0 implementation and does things a little differently than Unity's Standard shader. You could totally make a surface shader that works the same way, but the Standard shader does not use the additional channels of the Metallic texture.

    However, as I've said before, the Standard Specular shader can be used to reproduce the Standard Metallic texture exactly, in fact they are almost exactly the same shader with a single extra function that converts the Metallic and Albedo textures into a Specular color. There's really no reason to use the Standard shader apart from it being slightly easier to use.

    You can recreate what the shader does in an art program by making a solid 56, 56, 56, then taking the metallic value and using it as a mask for the albedo texture as a layer over that. After that you can make areas you don't want to have any specular fully black.
     
    ArachnidAnimal and theANMATOR2b like this.
  3. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,815
    I spent a few hours today just looking through the CGIncludes and looking at the .gcinc files. I think found the code in the UnityStandardUtils.gcinc file:

    Code (csharp):
    1.  
    2. inline half3 DiffuseAndSpecularFromMetallic (half3 albedo, half metallic, out half3 specColor, out half oneMinusReflectivity)                                
    3. {                                
    4.    specColor = lerp (unity_ColorSpaceDielectricSpec.rgb, albedo, metallic);                            
    5.    oneMinusReflectivity = OneMinusReflectivityFromMetallic(metallic);                            
    6.    return albedo * oneMinusReflectivity;                            
    7. }
    8.  
    So I see what you mean now/
    Apparently the unity_ColorSpaceDielectricSpec.rgb is fixed at (0.22 0.22 0.22 0.779), according to this:
    https://forum.unity3d.com/threads/how-to-set-unity_colorspacedielectricspec.339625/
    http://catlikecoding.com/unity/tutorials/rendering/part-4/Rendering-4.pdf
    (I can't find where it's actually defined anywhere in the .gcinc files)

    In my case, the problem was with the red channel of the metallic map. I had it pure black, which meant the specColor was becoming just unity_ColorSpaceDielectricSpec.rgb. This explains the grayness specular.

    So I changed the red channel to have higher metallic in the smoke area. This causes the specColor to be closer to the albedo color, which is black.

    For the metallic workflows I've already done, I think I just have to go back and increase the metallic values, to get the specular colors closer to the black which is in the albedo textures. This is probably the easiest "fix" for this.
     
    Last edited: Jun 22, 2017
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    It's not set by any cginc file, but set by the game engine. I believe it changes depending on if you're using gamma space or linear space, hence the "ColorSpace" part of that variable name. However, yes, a black albedo and full metallic should get you areas with no specular, but it's possible you might get a bright edge around the black, so you probably also want to set the smoothness to black as well.