Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Shadow artifact at corners of meshes

Discussion in 'General Graphics' started by MSoderberg, Mar 1, 2020.

  1. MSoderberg

    MSoderberg

    Joined:
    Jun 14, 2019
    Posts:
    20
    I see these shadow artifacts appearing at the corners of meshes. I see it in all versions and in all rendering pipelines (the effect is more pronounced in the LRP).

    What is this and how can I get rid of it?

    corner_artifact1.png corner_artifact2_lwrp.png
     
  2. mouurusai

    mouurusai

    Joined:
    Dec 2, 2011
    Posts:
    349
    Shadow acne
     
  3. cholleme

    cholleme

    Unity Technologies

    Joined:
    Apr 23, 2019
    Posts:
    25
  4. MSoderberg

    MSoderberg

    Joined:
    Jun 14, 2019
    Posts:
    20
    Thanks for letting me know. Seems like a real bullshit problem - it doesnt seem easy to remove completely. I tried changing the bias in the lighting settings but that brought on other problems. It seems best to adjust the angle of the directional lights so that the effect are not seen by the player.
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    Yep. It's a problem AAA games struggle with. It's usually solved by careful planning of light direction and geometry, but you can find it in the latest games if you look for it. Most games will err on the side of overly blurred shadows with "peter panning", which is what it's called when you have a very high bias to push the start of the shadow away from the casting surface, which can sometimes cause objects' shadows to not connect to the place they touch the ground. To hide that several modern games make use of AO or screen space shadows, and now raytracing, to cover the gap.

    This example from Nvidia's official post on Control's use of Raytracing is a good example.
    https://images.nvidia.com/geforce-c...e-comparison-001-all-rt-on-vs-all-rt-off.html
    On the left side the chair legs cast nice sharp shadows on the floor, grounding them in the scene. On the right the shadows fade in over some distance so the legs appear floating. Other places like the jacket or the fingers on her hand are casting shadows where they otherwise wouldn't be.

    Unfortunately Unity's built in shadows aren't using the latest shadowing techniques. They're essentially using the same techniques games were 10 years ago, with some optimizations to the technique made about 4~5 years ago so the same effect would be cheaper (that could have been, and probably was being done before that by other games). If you want better shadow quality in Unity, you either need to upgrade to the HDRP, or try something like the Next Gen Soft-Shadows asset on the store.
    https://assetstore.unity.com/packages/vfx/shaders/next-gen-soft-shadows-137380

    Note. In extreme cases like a directional light facing straight down on a box, even the HDRP or that asset will likely still have some artifacts like you're seeing. There just isn't a complete solution for that case.
     
    MSoderberg likes this.
  6. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
    Predulus likes this.
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    fuzzy3d likes this.
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    In some ways path tracing is actually worse than shadow mapping for this specific case. Vertex normals and the resulting interpolated normal on the face is an illusion, and it's entirely possible and even expected that the interpolated normal can be facing towards the light in places where the actual surface is facing away from it. With path tracing producing accurate shadows, this can lead to situations like above. For non-realtime rendering this is one of the reasons why there's a heavy reliance on very high polygon or b-spline based surfaces. For realtime rendering using Phong tessellation can help alleviate this problem.
     
    fuzzy3d likes this.
  9. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
    I'm sorry, I deleted my post because it seemed to me that I was probably making a basic mistake and I have to search the forum ...
    This is path-tracing:
    upload_2021-3-29_9-48-5.png
    This is unity native Sphere object and Directional light. It only improves if I increase the angular diameter of the directional light.
     
    Last edited: Mar 29, 2021
  10. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,068
  11. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    fuzzy3d likes this.
  12. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
  13. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    Bakery is an offline path tracer. The problem is the same, only the output is different.

    You can't fix the problem with the technique described in that link, though Unity could if they were inclined to modify their ray tracing shaders to use the same work around. However the tessellation shader should produce the same results, assuming it works with HDRP's ray tracing.
     
    fuzzy3d likes this.
  14. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    fuzzy3d likes this.
  15. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
    So the only way to eliminate this feature is to find a shader that will have better features?
    Edit: It is interesting. This is a scene with ray-tracing (not path-tracing) but the type of light is the same-directional, angular diameter 0.55.
    upload_2021-4-5_10-39-39.png
    But if I try to turn on raytraced shadows for this light:
    upload_2021-4-5_10-40-40.png

    The implementation of ray-tracing and path-tracing is probably not finished yet.
    O.K. now we have to find a way around it so that we can use it already in this state. Probably a different lighting scenario.
     
    Last edited: Apr 5, 2021
  16. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,255
    There's no real difference between "ray tracing" and "path tracing" because they're not separate things. Path tracing is a specific form of ray tracing. Anyone who tells you they're "totally different things" is really just confused by the fact so many different rendering techniques are under the umbrella of ray tracing and aren't given a specific name. It's like arguing that an apple and a Honeycrisp are totally different things ... a Honeycrisp is a specific type of apple, but still an apple.

    Even Unity's own documentation says the same thing in the first line!
    https://docs.unity3d.com/Packages/c...ion@10.4/manual/Ray-Tracing-Path-Tracing.html
    One thing Unity's documentation leaves out is each recursive ray's direction is randomly scattered based on the roughness of the surface. Also "reflective" in this specific context includes diffuse surfaces.

    Really all ray tracing is, is calculating a ray through some set of geometry / shape data and finding the points of collision between the two points. This can be used to render an unlit object by tracing from the camera to some arbitrary point in the distance to find the closest surface, or between a surface position and a light to see if there are any other surfaces between it and the light for shadows. Unity's "ray tracing" is doing the later, but still using rasterization to find the surface. Except for ray traced reflections and refractions, which are using rasterization to find the first surface, and then ray tracing the same scene data to find the next surface position.
     
    Last edited: Apr 5, 2021
    fuzzy3d likes this.
  17. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
    In practice, the difference between path tracing and ray tracing is now that- for ray tracing "without path tracing" I can turn off raytraced shadows for directional light and the artifacts in the shadows are gone.
    This option has no effect in ray tracing with enabled path tracing and problems remain.

    Ray tracing and path tracing give such very different results that I also considered them to be two different technologies...
     
    Last edited: Apr 5, 2021
  18. JanKrocak

    JanKrocak

    Joined:
    Jul 11, 2021
    Posts:
    13
    Hi. I had the same problem but what seemed to solve it for me was Ray Bias under RayTrace Setting in the Volume Overrides.
     

    Attached Files:

  19. fuzzy3d

    fuzzy3d

    Joined:
    Jun 17, 2009
    Posts:
    225
    Hi, thanks for the reply but unfortunately it doesn't work. I will try to install a newer version of Unity and try again.