Search Unity

Soft shadows cause white pixel artifacts everywhere

Discussion in 'General Graphics' started by xVergilx, Jun 23, 2019.

  1. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    Title.

    GIF.gif

    Is there a way to avoid these artifacts without disabling soft shadows completely?
    Worst part of this is that they get picked up by bloom effect, causing even more artifacts =\

    FXAA post-effect seems to be helpless against those as well.
     
    Last edited: Jun 23, 2019
  2. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,846
    The problem you are having with over bright pixels can come from your shader or post-processing, default shadows or NGSS shadows don't do that and I'm afraid you will have the same problem with NGSS.
    Just curious, what Unity version and what GPU do you have?
     
    xVergilx likes this.
  3. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    Unity 2019.1.2f1, on DX11, GTX 1050 TI, on a built-in renderer (non SRP). Both in Editor and in Build on the same rig.
    I haven't really payed attention when these appeared, probably ages ago when I've added Post Processing Stack v2.

    I've also been using built-in shaders for a while, and those had these artifacts as well as Lux Plus.
    White pixels do showup only if I have a realtime light + soft shadows enabled. No artifacts with hard shadows only.

    So, no idea whats up with soft shadows. It could be Unity's bug.
     
  4. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,846
    Try updating your GPU drivers and try disabling Postprocessing stack. I sure is not Unity shadows cause is the first time I see it. If you are using Lux, try using a standard shader instead and see what happen?
     
    xVergilx likes this.
  5. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,846
    The shader you are using might over-brightening some pixels, make sure your are not having extreme values on it. If you want to know if it comes from your shaders use a saturate function before returning the fragment color and if it goes away is your shader and needs to be fixed (over-brightening must be scaled to 0-1 range).
     
    xVergilx likes this.
  6. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    I've been using standard, then transitioned to Lux Plus. In both cases white pixels showed up.
    Also, gif taken above was from Scene View. I doubt it is affected by post-processing stack, so I don't think I can disable it. Probably unistall of PP only can tell.

    The above. These appear on all surfaces without any relation to the shaders used. E.g. above gif taken from terrain, and those appear on meshes as well.

    What I should try first is to upgrade drivers + Unity I guess.
    Although I haven't noticed any issues with soft shadows in any other game installed on my PC, so idk really.
     
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,846
    Post Processing also acts on Scene View. Update drivers and disable PP see if it goes out. This looks clearly an out of range value on those pixels, like way too bright.
     
    xVergilx likes this.
  8. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    I've tried both updating drivers + Unity to v2019.1.8f1, no luck. So the only thing left to try is complete removal of PP.

    BUT, I've found this thread:
    https://forum.unity.com/threads/fixing-screen-space-directional-shadows-and-anti-aliasing.379902/

    Which got me thinking, if those are artifacts are the directional light shadow issues.
     
  9. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    6,984
    The issues in that thread are caused by having the main scene rendering use MSAA while the shadows are rendered to a non-MSAA buffer. They also exist regardless of if you have soft shadowing or hard shadowing enabled. Your issue is entirely unrelated.

    My questions would be:
    What does the mesh that is casting the shadow look like? Do those dots line up with some feature of that mesh?
    What does the geometry you're currently rendering look like? It looks like a mostly flat plane, but is there some extra geometry there?
    How bright is your main directional light? Does changing the color or lowering the intensity of the light those dots to change?
    Step through the frame debugger. When do the dots show up? Are the visible in the main directional light's shadow receiving pass? Do they only show up after post processing?
    If they only show up after post processing, are those dots black before then? At what point do they show up black? Is HDR enabled on the camera, and does disabling HDR make them go away?
     
    xVergilx likes this.
  10. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    3,846
    On top of what bgolus suggested, I would also suggest to try to debug any shader you are using and try to cut the range of the final color (using saturate or max functions) and disable any PP. If you are using a standard shader, try using a custom unlit shader that you can debug easier. You can find many examples in the Unity doc, look for them on google.
     
    xVergilx likes this.
  11. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    I don't think those are caused by the mesh. I might be wrong though.

    upload_2019-7-6_9-52-50.png
    Both default terrain and custom meshes have them.
    I've got a large spot at the center of the map (which is about 2.5km / 2.5km), as well as directinal light.
    However, disabling them completely or lowering intensity does nothing against those.
    Good thing I've tried again. It seems like Unity 2019.1.8f1 did help a bit as those artifacts now tend to show up only in scene view BEFORE camera with PP is loaded.

    Need to test the build as well.
    GIF.gif

    After aligning game view empty camera with no PP attached to it,
    upload_2019-7-6_10-23-52.png

    It seems like those appear in Frame Debugger after RenderDeferred.Lighting -> Shadows.RenderShadowMap -> Shadows.RenderJobSpot -> Draw Mesh. And they're visible there as black dots.

    blackdots.PNG
     
  12. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    6,984
    This is looking like a long time bug with baked directional ambient lighting. Somewhere in Unity’s shading code, something is causing NaN values to be written to the gbuffers. That’s getting picked up by the lighting code someplace and ends up written out as infinity. Post processing will then see that and cause bloom to freak out.

    I comes up every so often, gets reported to Unity as a bug, and it gets marked as “will not fix” and closed.

    :(

    I spent some time tracking it down during Unity 5.3, but ended up never finding it as we chose to cut baked lighting instead. Amazingly fully real time lighting was faster than baked lighting for PSVR.
     
    xVergilx likes this.
  13. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    1,875
    It does seems like an editor bug. Build doesn't have this issue for me anymore on Unity 2019.1.8f1.
    Either upgrade fixed it somehow, or GPU driver update.

    I think the proper way to ensure this is not persistant in future builds is to make an option for "hard & soft" and "hard only" shadows for the settings menu. At least it won't be an issue for potential users.

    Also, it is full realtime lighting, so it could be that rendering code is still messed up somewhere in the source.