Search Unity

Unwanted View-dependent Lighting With "high Quality" Standard Shader In Deferred Mode

Discussion in 'General Graphics' started by briank, Apr 15, 2019.

  1. briank

    briank

    Joined:
    Mar 25, 2017
    Posts:
    74
    I'm using a custom surface shader. Regardless of the lighting type (Lambert or standard) and with respective specular/smoothness/metallic/emmisive all set to 0, there is always a noticeable sheen on the mesh. As you can see in the video, it's view dependent.

    https://imgur.com/a/7pLX34y

    Given the parameters, I'd expect pretty much just a diffuse sort of lighting.

    I've narrowed down the cause to the sheen to the deferred renderer. It does not repro in forward... Moreover, it does not repro with medium or low quality standard shader. Only the high quality standard shader.

    If there are any ideas or tips to remove this sheen, I'd be curious to try them. I'd still like to be able to support any standard shader quality level and render mode though, so simply using medium quality/forward isn't an option unfortunately.
     
  2. briank

    briank

    Joined:
    Mar 25, 2017
    Posts:
    74
    I tracked it down to the BRDF function used in the deferred shader pass that combines all the lighting data.

    In a high quality standard shader, the DisneyDiffuse function is used to compute the diffuse term. Commenting out the viewScatter term removes this weird shimmery artifact that I see.

    Code (CSharp):
    1. // Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.
    2. half DisneyDiffuse(half NdotV, half NdotL, half LdotH, half perceptualRoughness)
    3. {
    4.     half fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
    5.     // Two schlick fresnel term
    6.     half lightScatter   = (1 + (fd90 - 1) * Pow5(1 - NdotL));
    7.     half viewScatter    = (1 + (fd90 - 1) * Pow5(1 - NdotV));
    8.  
    9.     return lightScatter * viewScatter;
    10. }
    Not sure what to make of this other than that I'm extremely surprised to see this shimmery effect with smoothness set to 0. Even looking at Disney's papers on their BRDF function, I don't see this sort of thing in their rough surfaces...
     
  3. briank

    briank

    Joined:
    Mar 25, 2017
    Posts:
    74
    Nevermind nevermind; Long investigation only to figure out that the normal being generated for my height map were wonky in the x-z direction. (x-z needed to be flipped, one the axes was inverted!).