Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Shadow Bias - no value is right

Discussion in 'Editor & General Support' started by andyz, Dec 6, 2010.

Thread Status:
Not open for further replies.
  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,295
    I have hard shadows on an outdoor scene - distance is only 80, four cascades, High-res and still I have issues.
    I need a very low bias to get rid of gaps between objects and their shadows (i.e hat and face).
    But when bias is virtually 0 artifacts appear on the terrain (although not very close up - perhaps a mip-map or cascade issue).
    Is this always the trade-off or is Unity not using the best shadow-map method?

    (I have one directional light casting the shadows)
     

    Attached Files:

    Last edited: Dec 6, 2010
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    This is a problem for any shadow mapping algorithm: too large bias, and casters are "disconnected" from receivers (called "peter panning"). Too small bias, and surfaces start to self-shadow themselves (called "shadow acne").

    There's no really good solution to this, except for "try to somehow make your scene/artwork to minimize the artifacts". For example, maybe bake ambient occlusion for the character, so that the disconnect between hat head is not visible since it will be inside AO anyway?
     
  3. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,295
    Indeed, though I've not seen as bad before - perhaps been lucky!

    Does Unity use Slope-Scale Depth Bias?
    Also can the shadow shaders be accessed somewhere and modified?
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Yes, we do use slope-scale depth bias.

    Shadow caster shader usually comes from a fallback, e.g. see "shadowcaster" pass type in VertexLit shader. Shadow receiver shader part is generated automatically when compiling a surface shader; you can see the code that it generates by using "#pragma debug" in the shader and inspecting shader output.
     
  5. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62

    I'm suffering shadow panning/acne problem too.
    It isn't natural enough to use artwork workaround.
    I've searched for days to get the solution for this but in vain.
    Please let me know more detailed workaround for this.

    Thank you in advance.
     
    Last edited: Dec 12, 2011
  6. i3DTutorials

    i3DTutorials

    Joined:
    Aug 26, 2010
    Posts:
    564
    mulova, bake AO passes for your textures. This is as standard as baking normal maps in today's standard pipelines.
     
  7. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    Thank you for the answer. But it doesn't look natural and can't handle the light direction change.
    I'd like to know how other games like 2K baseball series solves this problem.
    They seem to fix this issue.
     
  8. i3DTutorials

    i3DTutorials

    Joined:
    Aug 26, 2010
    Posts:
    564
    :p

    Of course they fixed the problem, do you know what kind of resources 2K Games has? Sorry, but I don't think Unity is at that point yet, but I'm pretty sure soon enough we'll be looking back saying "...remember when Unity couldn't do that?"
     
  9. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    Thank you for the reply. But I never said "Unity can't do this".
    I'm surprised everyday by the unity's power and flexibility.
    I know of course they can. But time matters.

    What I'm gonna do is making AAA games like 2K series using Unity3D.
    I just need it now because this is critical to my project.
     
    Last edited: Dec 14, 2011
  10. mulova

    mulova

    Joined:
    Apr 14, 2011
    Posts:
    62
    Is it possible to have a mesh which is not visible but only rendered for shadow?
    Then I'll use it as workaround for this problem.
     
  11. Stevepunk

    Stevepunk

    Joined:
    Oct 20, 2013
    Posts:
    205
    This is still an issue.
    As I'm using low poly graphics without textures I can't just "change the artwork"
    Also, for some reason it's only a problem with soft shadows (hard shadows are ok but don't match the aesthetic).

    I can't believe that it's been over 5 years and this is still a problem..
     
    Ignacii likes this.
  12. Zarod

    Zarod

    Joined:
    Jan 20, 2016
    Posts:
    67
    a bit late but the only solution for us currently is to add geometry where the problem occurs. in every house the roof makes this error so we added a mesh to the prefab and set it to shadow only in some cases or separated the geometry in various meshes so to spread them in different draw calls ( that seems to be the problem calculating the shadow of edges of a big single entity). hope it helps

    also Ambient occlusion is irrelevant to us, it draws only near edges, not on their shadows
     
  13. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Any better solution to this now in 2019? Still a problem 8 years later. Particularly seems to be a problem when a character is on a reflective surface or with multiple light sources.
     
    Last edited: Feb 13, 2019
    Alvarezmd90 likes this.
  14. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    164
    Yeah, Unity is stagnating graphics wise. Struggling with shadow bias too.
     
    LaireonGames likes this.
  15. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You'll need to move to HDRP to address that (it has the best shadows I've used) but yeah builtin isn't going to improve.
     
  16. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    I solved it with NGSS, but its a lot of added complexity. If you're starting a new project, use URP/HDRP.
     
    Alvarezmd90 and Lipoly like this.
  17. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    And this is the problem with Unity. If you are starting a new project DO NOT use any render pipeline. Them being labelled as production ready is a blatant lie and probably wont be for a year. It doesn't even support shadows for point lights yet...

    https://portal.productboard.com/8uf...s/3-universal-render-pipeline-previously-lwrp

    Honestly if you are starting a new project that will be done within a year, choose a different engine.
     
  18. HugoZink

    HugoZink

    Joined:
    Mar 4, 2018
    Posts:
    13
    HDRP isn't production ready yet by any means, not until we get the option to make our own master nodes. Or until the documentation on manually coded shaders is actually made. Until that point, it's a neat little demo, nothing more.
     
    LaireonGames likes this.
  19. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I see you need custom lighting. I've been doing that for a while actually in URP and HDRP. That's what emission node is for. You can completely ignore Unity's own lighting then. In my case I use a little of both Unity's and my lighting.

    Is there something stopping you in some way? Please make a new post if that's the case.


    I've locked this thread as it's being pulled in different directions. Be sure to make a new thread for your own issues in a relevant graphics sub-forum.
     
Thread Status:
Not open for further replies.