Search Unity

Legacy difuse on plane

Discussion in 'Shaders' started by VictorKs, Feb 26, 2021.

  1. VictorKs

    VictorKs

    Joined:
    Jun 2, 2013
    Posts:
    242
    So I have a large plane with a green color. Why when I look away from the sun the plane becomes brighter and darker when looking towards the sun? Using Legacy Diffuse shader.

    Shouldn't diffuse lighting be the same for whole plane? Tested with low sun 25 degrees
    BTW this only happens in defered in forward it works as it should why is that?
     
    Last edited: Feb 26, 2021
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,343
    When using the deferred rendering, Unity only supports opaque rendering using the Standard shader which uses a different diffuse shading model than Legacy Diffuse's Lambert shading model. The Standard shader uses an approximation of Oren-Nayar diffuse called Disney Diffuse, so named because it's what Disney uses for their animated films. When you switch to deferred, Unity approximates Lambert with a Standard Specular setup that uses a black specular color and a smoothness of 0.0. That's unfortunately the best compromise of settings to approximate the lambertian diffuse model.

    upload_2021-2-26_10-12-16.png

    Supporting only a single shading model is a fairly common feature for deferred renderers, so this isn't some unique limitation of Unity. There are deferred renders that support a more diverse range of materials, including some you can download on Unity's asset store to replace / augment Unity's, but they come at the cost of being more expensive to render.

    If you absolutely need it to be lambert, you'll either want to stick with forward rendering, or you'd need to modify Unity's shaders to add a special flag in the gbuffers to force lambertian diffuse.
     
    VictorKs likes this.
  3. VictorKs

    VictorKs

    Joined:
    Jun 2, 2013
    Posts:
    242
    Thanks a lot for the information, I understand the need for a single defered shading model. I am just trying to learn about lighting models and pbr to improve my graphics quality. Not reverting back to lambert :) Thanks again!