Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Realtime shadow artifacts when using custom half lambert lighting

Discussion in 'Shaders' started by CaffeinatedCoolaid, Jun 5, 2021.

  1. CaffeinatedCoolaid

    CaffeinatedCoolaid

    Joined:
    May 10, 2021
    Posts:
    59
    I'm using URP and have a modified Lit shader to use half lambert lighting, everything is fine except I'm getting weird gradient artifacts on surfaces facing away from the lights with soft shadows.

    shadowerror.PNG

    I cant seem to figure this out, I'm pretty sure its related to the shadow sampling itself but haven't been able to pinpoint it. Any one else have a issue with this or a possible fix?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    It’s kind of the problem with half lambert shading, or any kind of shading that pushes the shading to the parts of the mesh facing away from the light. Technically this can happen on any mesh using the Standard shading model if using extreme normal maps too.

    Shadows on the back side of objects tend to be quite ugly as you're able to see the shadow artifacts that are normally being hidden by shading. Basically this is a "common shadow acne" artifact that you can also see on the front side of surfaces when you have lights close to perpendicular to a surface, or when you have a very thin object casting shadows onto another very close object. You can sometimes fix it by increasing the bias settings on your light. In one case I worked around it by changing the shadow caster to use
    Cull Front
    instead of
    Cull Back
    . But both of these solutions come at the cost of increased peter panning ... the name given to when the shadows from an object no longer appear to connect to the object or disappearing entirely. But those are the limitations of shadow mapping.
     
    CaffeinatedCoolaid likes this.
  3. CaffeinatedCoolaid

    CaffeinatedCoolaid

    Joined:
    May 10, 2021
    Posts:
    59
    Thank you! "Shadow Acne" was the term I needed to look up on!