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

White pixel aliasing from directional light on edges

Discussion in 'Global Illumination' started by sazberryftw, Mar 5, 2018.

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

    sazberryftw

    Joined:
    Dec 12, 2016
    Posts:
    39
    Hey,

    I was wondering if anyone can explain to me what this issue is. It happens on edges that are shadowed when using a realtime directional light where the background is lit. It's not specific to my meshes or my scene or my lights, it happens if you make a fresh scene with the default directional light and a cube.

    I'm using forward rendering, Unity 2017.1.1, MSAA 2x (increasing this doesn't fix it). It stops happening if you turn anti-aliasing off.

    I've searched for threads about it, but couldn't find any posts more recent than 2015. Is this just a general issue with MSAA?

    aliasing.png
     
  2. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Had the same problem, I think it is above objects with transparency?
     
  3. sazberryftw

    sazberryftw

    Joined:
    Dec 12, 2016
    Posts:
    39
    I don't think so? You can get it happening with generic Unity cubes using the default material. You just have to have a shape in shadow, then look at that shape in front of a lit surface, and you get the edge aliasing.
     
  4. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Oh, you´re right, even worse!
     
  5. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hello. There could be numerous reasons why this is happening. If you could attach a link to your project where the issue is present, we could take a look. Thank you!
     
  6. sazberryftw

    sazberryftw

    Joined:
    Dec 12, 2016
    Posts:
    39
    Hi! Here's a link https://drive.google.com/open?id=1vmNHvwNOL0IzuvmLJnJVQwdn7ezba8te

    Just as a note I can't use FXAA, deferred rendering or turn off MSAA for my project.

    Screenshot of the scene in that project:
    aliasing.png
     
    Last edited: Mar 6, 2018
    BinaryCats likes this.
  7. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hello again, @sazberryftw

    We've had the chance to look into your project, and it is a know issue which actually has been reported before. Here is the link to the Unity Issue Track page - https://issuetracker.unity3d.com/issues/edge-of-a-cube-flickering-when-in-a-shadow-of-another-object

    One of my colleagues, Kemal Akay, has previously responded to the previous reporter of the issue. Since you are experiencing the same problem, I will paste his reply below:

    Hey,

    Thank you for reporting this issue. However, this was already a known problem in our render pipeline and essentially, it has not ben fixed because of performance reasons. And it will be addressed later with Scriptable Render Pipelines, introduced as an experimental feature in 2018.1 beta. As a workaround, you can do a couple of things:
    - Change rendering path from Forward to Deferred if applicable
    - Use Soft Shadows instead of Hard Shadows
    - Disable MSAA


    We also observed that the issue doesn't occur on Metal API.

    Our developer provided more insights about the problem so I'm also sharing them if you're interested:

    This is an artifact due to our handling of MSAA. Not the entire pipeline is MSAA aware, probably because of the performance implications. In this particular case the depth pre-pass is only single sampled and the screenmask shadows are calculated based on this depth buffer. The scene itself is then rendered using MSAA.

    Why this goes wrong:

    - The edge of a triangle is not covering the pixel center, so nothing is written into the depth buffer
    - The screenmask shadow uses this depth buffer and calculates one shadow value per pixel
    - The forward pass renders in MSAA and now the triangle is covering one sample in that pixel. It uses the screenmask to fetch shadow information, but this mask was calculated based on the incorrect depth buffer. So the sample receives the shadow result from whatever was behind the object. If nothing was behind it, e.g. only the skybox, then the pixel will be marked as lit.


    In order to do this properly the prepass would need to also be rendered using MSAA, the screenmask would have to be MSAA and would need to be calculated per sample. The forward shader would then need to get the coverage mask and resolve per sample which would probably be just too expensive to do, so that's why we haven't done it and are not going to do it.

    Thank you for reporting the issue and helping us. We hope this answers your question and since it will be addressed later, I'll be closing the report. If not, feel free to reply to this case to re-open it.

    Best regards,
    Kemal
    I am sorry that we are not able to provide you with a fix to your case, regarding this issue at the moment. Rest assured, however, that the team is working hard to resolve it in the upcoming Unity versions.

    Sincerely,
    Kristijonas
     
    Last edited: Feb 13, 2020
  8. sazberryftw

    sazberryftw

    Joined:
    Dec 12, 2016
    Posts:
    39
    Thanks for the detailed explanation. Hope this helps anyone else looking for info about this. For now we're disabling MSAA and using render scale as we are developing for VR.
     
  9. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    I'm also seemingly one in a long line of people to come across this a year ago now, but it stretches back years:

    https://forum.unity.com/threads/light-dark-pixels-along-the-edge-of-objects.465511/#post-3045775

    I'm surprised at this official answer, because first, it isn't just "his case", it's a pretty serious general problem, and a deep one at that, and also because I was expecting it to be "we fixed that with the new rendering paths in 2018"...
     
    BinaryCats likes this.
  10. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    I'm seeing this as well in my VR project and it's very noticeable. Has this been fixed yet in the newer Unity releases?
     
  11. chrixxxtopher

    chrixxxtopher

    Joined:
    Apr 8, 2018
    Posts:
    6
    This still happens on most current version of Unity (2018.3) . I have read blogs dating from Unity 3 regarding this.
     
    BinaryCats likes this.
  12. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
  13. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,115
    This is from 2016 and it is a known issue, but Unity hasn't fixed it yet? I find it strange that we are forced to work with a workaround 2 years later. The two solutions don't seem overly complicated to implement either, so I don't understand why this was just left as it is.

    Providing anti-aliasing option to the screen space shadow depth path can't be that difficult nor is centroid sampling (both cases have a working code). So why is Unity not spending time to fix it. This is a bug. It is an unintended outcome and is not what most users would know right away. Either show warnings on the inspector, or provide options (a toggle option with screen space shadows and MSAA) so that users can actually decide.
     
    BinaryCats likes this.
  14. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    His "workaround" is actually in a thread from early 2015, so three years. Still, pretty incredible that such a basic bug has been allowed to be around for so long.

    Has anyone tested if LWRP or HDRP fixes this yet?
     
  15. BinaryCats

    BinaryCats

    Joined:
    Feb 8, 2016
    Posts:
    317
    I have not but my guess it would not be resolved. However you could solve it by using your own custom scriptable render pipeline o_O:confused::(
     
  16. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    Five years now and counting, at least for the built-in pipeline.
     
    Benfont and BinaryCats like this.
  17. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    This issue will not be fixed for the built-in RP. For reasons why, please see my response above.
     
Thread Status:
Not open for further replies.