Search Unity

Anti-aliasing not so good against real-time shadows

Discussion in 'Editor & General Support' started by andyz, Oct 20, 2010.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    1,101
    If I turn multi-sampling on then it generally looks nicer but the extra samples don't seem to pick up shadow-mapping - the result being that edges against shadow don't look so great at times as there are over-bright pixels along them. (see attached image)
    I've not worked with shaders for a long time so I don't know if this is a typical minor trade-off for speed or if it can be improved at a small cost...
     

    Attached Files:

  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,603
    thats normal and doing something about it is not trivial ... thats why it too graphic cards so long until they got transparency AA ...
     
  3. Septem

    Septem

    Joined:
    Feb 3, 2011
    Posts:
    5
    So can someone give an idea how to solve this issue? Because I also faced this problem and want to do something to solve it on Unity 3.5
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,535
  5. Septem

    Septem

    Joined:
    Feb 3, 2011
    Posts:
    5
  6. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    478
    Is it really normal? (I've run plenty of PC games with shadows+multisampling which don't exhibit this sort of glitch)

    I was just experimenting with shadows in a test scene, and with 4x multisampling enabled (forward rendering, default diffuse material, one directional light, Unity 4.2), it can look very rough:

    $shadowtest.png

    I don't see the connection with transparency AA here. Yes, multisampling only runs the shader once per multisampled pixel - which is fine. But why is the shader failing to correctly apply shadows to these edge pixels?

    What are Unity's shaders/renderer doing that isn't compatible with multisampling? - there's also been issues with specular shaders exhibiting some ugly artifacts when multisampling is enabled: http://forum.unity3d.com/threads/82887-Fireflies-Anti-Aliasing/page3

    Are the shadows being applied in a second render pass? - Or in the 'ForwardBase' pass? If it was doing deferred shadowing, I could understand the glitch, as deferred techniques don't go well with multisampling. But I really didn't expect that it would do that in forward rendering mode?

    Edit: After looking at the shader code from \CGIncludes, I suspect that Unity is building a shadow depth buffer in screen space (to combine the cascades?). This would explain why it doesn't work with MSAA :(
     
    Last edited: Aug 18, 2013
  7. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Yeah, I noticed this too, and kinda cried at the performance waste as it happens even with a single cascade.
    Also unitys cascades...
    1 Casced is 1 4k map
    2 Cascaeds is 1 4k x 2k map. (So less total resoultion...)
    4 Cascades is 1 4k x 4k map. So now even the best of our cascades has only 2k resolution.

    To start with I'd like an 8k shadowmap at 16bit's per pixel. Sure it's a whopping 128 mb, but really, that wouldn't be so bad for todays desktops that have easy 2Gb of VRAM.
    In addition to that it would have been nice with some other stuff for the shadows, but for now, that and removing the extra pass when only 1 cascade exists would be nice.