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

Why are directional light shadows so jaggy?

Discussion in 'General Graphics' started by JoeStrout, May 20, 2018.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I usually light my scene with a directional light, because it's a good simulation of sunlight, and because I imagine directional lights to be cheaper than point lights.

    But man, they produce lousy shadows, in my hands at least:

    upload_2018-5-19_16-30-37.png

    I've tried playing around with the quality settings, and I can make the jaggies smaller, but not eliminate them completely. But I can't believe this is the intended effect.

    Am I doing something wrong? How do you get nice clean shadows of even simple objects like these?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    A cube with just the default settings in a new project results in this:

    Screen Shot 2018-05-19 at 8.05.30 PM.png

    So check your quality/light settings; e.g. you wouldn't want the shadow distance to be huge or not have cascades.

    --Eric
     
    JoeStrout likes this.
  3. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I believe your shadow settings are: no cascades, hard shadows only (edit: actually not, default unity shadows just look that bad, even when set to soft), fairly low resolution. I recommend you try going to the quality settings and setting: hard and soft shadows, at least medium or high resolution, shadow projection "stable fit" (makes it jaggier on a static image but I think it causes less jitter in aliasing artifacts when you move your head), shadow distance not too high (I use 50 at the moment - depends on your scene), two cascades (possibly four depending on scene, not sure if VR can deal with that), first cascade set to about 20% (afaik that means the first 10 m of your view get their own shadow cascade (there should be a visualization of it in scene view as you tweak the limits) and things further away get blended into another cascade), and the settings of your directional light need to be "soft shadows" and not override the resolution to be lower than what you've set under quality settings. Trying that it still looked bad for me at first, so it seems you also need to go to the "graphics settings" and manually override the defaults for the 3 hardware tiers to all enable cascaded shadows (probably not recommended on all tiers, but if you build for Oculus Go there only is one device at the moment anyway). In my case that made the shadows much nicer on the left eye, but vanish from the right eye -_-.

    Is this a bug? I don't see lack of cascaded shadows mentioned here when I do a text search:
    https://docs.unity3d.com/Manual/SinglePassStereoRendering.html
     
    Last edited: May 27, 2018
  4. Forest3

    Forest3

    Joined:
    May 3, 2014
    Posts:
    15
    Replying to this old thread given this is one of the first results I got in Google.

    For me, changing Shadow Projection in Quality Settings, from Stable Fit to Close Fit, did the trick. Hope it helps.
     
    PacoLabs likes this.
  5. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    71
    Thank you! It definitely helped!
     
  6. GetLitGames

    GetLitGames

    Joined:
    Sep 24, 2014
    Posts:
    11
    The other thing is to check your default Quality Settings for what happens when you hit Play in the Editor. It doesn't show a resolution/quality dialog, it just goes with what you have highlighted in green in the Quality of Project Settings and set it to Ultra so that you see everything correctly.
    upload_2019-10-25_22-56-31.png
     
    JoeStrout likes this.