Search Unity

Feedback Shader graph PBR Metallic seems to need colour space conversion..bug?

Discussion in 'Shader Graph' started by EXP_Dev, Feb 18, 2020.

  1. EXP_Dev

    EXP_Dev

    Joined:
    Jun 9, 2016
    Posts:
    6
    Hey,

    I'm not sure if this is a bug or expected behavior. In the attached image I have made made 2 shader graph PBR materials and compared them too the built in lit shader with metallic values set at .25 .5 and .75.

    As you can see when the input on the metallic isn't converted to linear from RGB that the final outcome is darker than the lit shader. When it is converted, it appears the same as the built in lit shader.

    The same isn't true for the smoothness value, converting it from RGB to Linear wrecks it.

    Can anyone provide any insight or should I post this as a bug to Unity?

    Thanks in advance.
     

    Attached Files:

  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    Here's is how the
    _Metallic
    property is defined in the Lit.shader's properties:
    Code (csharp):
    1. [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
    That
    [Gamma]
    at the start of the line means Unity applies an sRGB gamma curve to the value before sending it to the shader, similar to how
    Color
    properties are gamma corrected depending on the project's color space.

    Currently the
    _Metallic
    property is the only one Unity uses this property flag on. The reason is because when using a Metallic & Smoothness texture it's generally expected that people leave it as an sRGB texture, so to ensure the slider matches the values you'd put into the texture, they added that property feature for Unity 5.0.

    Shader Graph currently lacks the option to flag Vector1 values as needing to be gamma corrected, so the correction does need to be applied in the shader manually if you want them to match. Humorously, the default Surface Shader that Unity creates for you when you create one from the project view is also missing
    [Gamma]
    on the
    _Metallic
    slider, and has had that bug now for 5 years, though at least in that case it was easy enough to add yourself (though most people didn't know they should).


    The other thing to think about is whether or not the metallic setting is linear or sRGB is arbitrary. Neither is more correct than the other.
     
    Peter-Bailey and chrismarch like this.
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    TLDR: Not really a bug, but is a missing feature.