Search Unity

Cast shadows problems on cubes and cylinders

Discussion in 'General Graphics' started by Dan_G, Jan 21, 2021.

  1. Dan_G

    Dan_G

    Joined:
    Dec 4, 2017
    Posts:
    31
    Hi all,

    I found a really strange issue in Unity 2019.4.17, 2019.4.18 and 2020.1.9. When i create a scene and a simple cube or a cylinder, it has some really strange shadows. It is like vertex of the mesh are sticking out from the geometry and therefore creating strange shadows along the mesh´s faces (see screenshots). I can fix it turning off Cast Shadows, but that obviously would remove all shadows casted from my object....It is a really strange problem, it happens just with these two 3D objects and sometime is more noticiable than others...

    I guess i am not the only one with this issue

    unity2020Problem3.png

    unity2020Problem4.png ?

    Thanks!

    D
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    This is a common shadow acne artifact caused by normal biasing. The easiest solution is to reduce normal biasing and increase the not-normal biasing on the light. But this leads to other issues like thin objects Peter Panning (there being a gap between the object and the shadow). You can fix that by reducing both types of biasing, but then you can get shadow acne across larger areas of the surface, and may see acne / darkening on further away shadow cascades. The last option is to never use models with sharp edges and instead use normal maps on smoothed meshes. This was pretty commonly the solution for big AAA games of the past.

    Shadow mapping is a collection of approximations and compromises. There’s no perfect combination of settings.
     
    M787 likes this.
  3. Dan_G

    Dan_G

    Joined:
    Dec 4, 2017
    Posts:
    31
    Thanks for your reply @bgolus ! Now i see where the problem is coming from.... I am using URP (7.5.2) and the Bias of the only light i have in scene was set to "Use pipeline settings". I changed it to custom, set the normal to 0 and Depth to 10 and the acne disappears. I wonder if it could be a problem with URP?

    I am surprised nobody has the same problem as this is happening to me in Unity 2019.4.18 with a fresh new project, no changes made on anything... Maybe i should move to 2020.1 to avoid these issues?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    This is a fundamental flaw with shadow maps. Period. It’s been an issue with them since they were first added to Unity 15 years ago, and will continue to be a problem until raytraced shadows replace them (which really just replaces the list of problems with a new list). Upgrading to a new version of URP won’t remove that.

    Almost every single game using real time shadows made in the last 20 years has had to adjust the shadow bias values to find an equilibrium between shadow acne artifacts and Peter Panning artifacts they find acceptable for their project. And I’m not just talking about Unity based games, every game that uses self shadowing shadow maps.

    That said, the URP ships with terrible defaults and is generally a step back from the built in rendering path’s defaults. They don’t seem to have fixed this in more recent releases that I’ve seen.
     
    M787, UnityMaru and Dan_G like this.
  5. Dan_G

    Dan_G

    Joined:
    Dec 4, 2017
    Posts:
    31
    Your comments/inputs are always great. Thanks a lot!
     
    UnityMaru likes this.