Search Unity

is this normal?

Discussion in 'General Graphics' started by laurentlavigne, Jan 25, 2020.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    directional light with shadow on, default shadow settings
    light bleeds through angles that are // to the light rays
    increasing normal bias gets rid of it but introduces other artifacs at grazing angle
    is this normal for the built in renderer? and are there ways to fix that?
    I'd jump to HDRP but some rendering things I use don't work with it.
    upload_2020-1-24_22-9-28.png
     
    Last edited: Jan 25, 2020
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    Yes, this is normal. It also happens in the HDRP too btw, it’s a pretty common problem with hard edges on meshes. I’m a little surprised increasing the normal biasing fixes it though, I would expect setting it to 0.0 would fix it better than setting it larger, though that would cause more issues at grazing angles.

    The problem is that to avoid shadow acne, shadow casting meshes are subtly shrunk in size by their vertex normal. For convex meshes this isn’t too bad, but on concave surfaces it can cause the edges to separate. The solution is to not use normal biasing, and use only the non-normal bias, or to update your meshes to use no hard edge in the vertex normals and use normal maps to make it look hard edged.

    Other options would be:
    Encode two sets of normals on your meshes and use a smoothed normal as the vertex normal so the shadow caster can use it, and the hard edged normal stored in the vertex tangents or an additional UV channel. Some of the toon shader assets on the store do stuff like this since the edge separation problem happens for mesh based outlines too.

    Change the screen space shadow receiver shader to enable
    UNITY_USE_RECEIVER_PLANE_BIAS
    , which is commented off by default. That should remove the shadow acne problems on glancing angles while letting you set the normal bias to 0.0. It’s not perfect and can cause some other artifacts, but it may be better than what you currently have.

    Use shadow caster only mesh renders with smoothed normal geometry for problem meshes. Disable shadow casting for the visible meshes and just use the “dummy’s” shadow instead. Could be as simple as duplicating the mesh asset and changing the imported normals to calculate with a 180 degree smoothing angle, and then duplicating the mesh’s game object(s). Sometimes you can get away with simplified proxy geometry if you want to spend a little more time on it.
     
    laurentlavigne likes this.
  3. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,327
    I'll just bake the hard edges in a soft edge model.

    Apart from shadows doing the same thing, what is your experience with HDRP? I see your posts are always very knowledgeable so that'll give me a different perspective.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    I don’t really have too much experience with the HDRP yet. For the games I’m working on it doesn’t make a ton of sense to use yet. We might start playing with the URP at some point, but there’s not a huge reason to do so yet.

    My comments on the HDRP shadows are more based on the fact both SRPs aren’t doing anything fundamentally different than the built in shadows when it comes to rendering the shadow caster pass, which is where the artifact comes from. They’ve got a lot of code for doing more complex soft shadowing techniques, some of which they don’t appear to be making use of last I looked, but that just means the same artifacts you’re seeing above will still appear, they’ll just be slightly blurrier.