Search Unity

SSAO Pro - High Quality Screen-Space Ambient Occlusion

Discussion in 'Assets and Asset Store' started by Chman, Oct 14, 2014.

  1. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Wow. Just tried your setup with the Forward rendering path and indeed, it breaks in a crazy way.

    I found what's causing it : Unity's [ImageEffectOpaque] attribute. This is definitely a bug (also in Unity 4 !) and it should be reported. It breaks SSAO effects, Global Fog, etc.

    If you go into SSAOPro.cs and comment line 257 (assuming you're working with an up to date version) you'll find out that it fixes the issue your getting... But it will cause SSAO to be "see through" on transparent objects.

    So unfortunately, I'm not sure if there's a good workaround for this bug, aside from switching to a deferred rendering path. A potential solution would be to render your cameras in a render texture and blit it on screen but it can be messy to set up...

    Edit: tested on Unity 4.6 and 5.0.1, 5.1.
     
    Last edited: Jun 26, 2015
  2. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    820
    Reimporting the project now until 5.1.1 to see if 5.1 fixed the issue, I'll report back if it doesn't. If not I'll try commenting out that attribute to see how things look. Thanks for helping with this, I know it's not a problem created by your asset and appreciate the time!

    5.1.1 didn't fix the issue, but commenting out that line did get us up and running until they fix the bug at least. Thanks!
     
    Last edited: Jun 26, 2015
  3. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Hi.
    It's not SSAO Pro bug, but I just wonder why SSAO Effect increases "Nature/Tree Soft Occlusion Leaves" so much. It's also happened with Unity Built-in SSAO.
    Each tree with no SSAO uses 3 draw calls with batching, but it spends 8-10 draw calls with SSAO.
    I don't want an AO to my tree leaves, but SSAO won't skip them. "Show AO" shows leaves itself with colored.
    ssao leaves.JPG
    Is there any way to avoid this? (My unity version is 4.6.1, deferred rendering / linear )
     
  4. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Not really, no. It has to do with render queues and the way Unity 4 generates the depth & normals buffers.
    I'm curious, that global grey tint tells me that you're working with AO mode 1.1 which can have some serious self-shadowing artifacts. Any reason why you haven't switched to 1.2 ?
     
  5. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Thanks for reply.
    I don't know which is self-shadowing artifacts, but I use 1.2 of latest version.
     
  6. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    725
    Arkade and Chman like this.
  7. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    So I'm currently having issues getting the SSAO Pro effect to render properly in a 2 camera setup. I was previously using the standard SSAO effect in Unity 4.6 on the 1st rendered camera set to clear flag of Skybox and the 2nd rendered camera (rendered "on top" of the 1st) was set to clear flag of Depth Only. This worked fine. I wanted to upgrade to Unity 5.1 though and now this does not work. I'm trying this new SSAO Pro effect and it doesn't work either. The 2nd camera seems to just be completely destroying the effect and/or depth buffer of the 1st. The Sun Shafts effect does seem to work, but only when placed on the 2nd camera. It seems to use depth info from both cameras. I tried placing the SSAO Pro effect on the 2nd camera then but that still does not work. Is there any solution for this? There has to be a way to use the depth buffer of both cameras if the built-in Sun Shafts effect seems capable of doing it just fine.
     
  8. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I have the same issue. It's a bug and/or limitation with Unity 5, image effects and multi-camera setups. See this topic. I sent a bug report to Unity a few weeks ago but haven't heard from them yet.
     
  9. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    Yeah, I've gotten around this by having my 2nd camera set to Forward rendering and just put all my image effects on my main 1st camera. I don't really need all the image effects applied to my 2nd camera since it's only for "weapons", but it would sure be nice to have it working on both cameras. I've never submitted a bug report before. Is there a way that I can add to the one you submitted so they know this is happening for multiple users?
     
  10. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Not that I know of unfortunately :/
     
  11. Michael-Thomas

    Michael-Thomas

    Joined:
    Jul 8, 2014
    Posts:
    20
    Any further update on this? Does the latest version still have these issues? Assuming it is not yet fixed, if it would be helpful, I can get access to a Radeon card for testing and can potentially help test if you have potential fixes to try.
     
  12. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,161
    The performance impact of this effect is independend from vertex/triangle amount of the scene, right?
     
  13. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yes. It will depend on the screen resolution and the SSAO radius.
    I'm currently testing a fix for another potentially related bug with the depth buffer (among a few other things). I'm waiting for someone to get back at me with the results (very soon hopefully). If it works, I'll send you a PM asap with the patched shader so you can test it ! Sorry it took longer than expected.
     
  14. FranckS

    FranckS

    Joined:
    Jan 14, 2014
    Posts:
    29
    Hey, we just bought your SSAO effect today and it's really good and flexible. Congrats.
    However it didn't work out of the box on PS4. Not much to fix but had to change COLOR semantic with SV_Target in all three shader sources. Just for you to know.
    Cheers.
     
  15. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Good to know, I'll add a define in the next version. Thanks !
     
  16. FranckS

    FranckS

    Joined:
    Jan 14, 2014
    Posts:
    29
    I also have the grid of dots when downsampling. AMD gpu in the PS4.
     
  17. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yeah that's my current focus, I really want to fix this annoying bug (among other things I already fixed) for 1.6 :/
     
  18. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    Hey there ! We are using your plugin on Unity 5, but on your scene it seems that activating the HDR mode on the camera makes the effect acting weird. It seems that it's inverted. We must keep the HDR, so how can it be fixed? thanks !
     
  19. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I use it with HDR enabled and I don't have this issue. Could you share a screenshot ?
     
  20. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    522
    @cayouMontreal Do you have anti aliasing disabled in your quality settings? That setting and HDR fight each other in a strange way. AA should be disabled if you're using HDR
     
  21. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,436
    AFAIK you can just use SV_Target regardless on any platform so a define wouldn't be needed? Have to check as I'm going off memory here.
     
  22. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    Thanks for replying, we discovered that HDR combined with command buffer decals will invert the SSAO pro (white is black and black is white). If I turn off HDR or remove decal command buffer on camera, everything is fine. But we must keep HDR and decals on our project. Do you have any idea why this is happening?
    You can test it easily by downloading the package from UT here:
    http://blogs.unity3d.com/2015/02/06/extending-unity-5-rendering-pipeline-command-buffers/

    I though we can just invert the result of SSAO but it might break at some point (due to extreme HDR values?).

    My 3d artist went crazy when we added the SSAO from Unity into the project (it adds a LOT visually), but unfortunately the original SSAO from UT doesn't provide any distance cut-off, and we have some far objects that we don't want to apply SSAO, that's why your plugin is perfect.

    Thanks !
     
  23. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    522
    That command buffer decal package is quite broken, and when we tried to extend it we found several bugs related to the Gbuffers, but only when using HDR. FYI
     
  24. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    Deferred decals are quite buggy indeed, if you try to destroy them sometimes they won't for example. But it's amazing how fast they are compared to a CPU way of doing decals.
    We do have a graphics programmer on our team, but he's quite busy these days, so I was looking for your help to get this amazing SSAO plugin into our game.
     
    Last edited: Aug 10, 2015
  25. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    I made some screenshots. The first one is without HDR/deferred decals, the second one is with both HDR/deferred decals.
    It seems that is inverted, maybe inverting result of SSAO might resolve this, dunno.
     

    Attached Files:

    Last edited: Aug 10, 2015
  26. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    You could try to invert the AO in the shader, see how it goes (around line 175 in SSAOPro.cginc, changing 1.0 - ao to ao should be enough). There are some weird banding artifacts on the inverted screenshot. FWIW I fixed a banding issue for the next update, not sure if it's related.
     
    Last edited: Aug 11, 2015
  27. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    I will try it out, thanks !
     
  28. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    As I might expect, the result is not exactly the inverse :-/
     

    Attached Files:

  29. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    FYI the native SSAO is working with both HDR and deferred decals, our graphics programmer will quickly try to modify the original SSAO to implement some cut-off option.
    It's weird that the native SSAO is working with these settings where yours is not, you must something that interfere with the deferred decals, but I don't know what.
     
  30. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I'll try and look into it, but SSAO Pro + HDR works fine in my test scenes. What happens if you set Lighting Contribution to 0 ?
     
  31. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    Same result, it's not because of the HDR alone, but mixed with deferred decals it breaks your plugin.
    We managed to modify the native SSAO to add a range on it, and it works well. We will go with that even if the original SSAO is not that beautiful. If you want to test it yourself, download the command buffers samples from Unity blog (link posted few messages above).

    We think it might also breaks another post effect we are using: SMAA from the community, because SMAA uses also the depth buffer to calculate things. That might explain why the result was barely noticeable.
     
  32. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    You mean this one ? I made this :p It only uses the depth buffer if you enable Predication & use EdgeDetectionMethod.Depth (not recommended anyway).
     
  33. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    Ahahah yes indeed :D
    It was just a assumption, on our game your SMAA is not changing a lot of things, the most noticeable aliasing is the "specular" one (we are using a shader with rim lighting). It seems working on certain objects only, it's hard to understand what's going on.
     
  34. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yeah unfortunately specular aliasing is a really hard case (there's some talk about it in the SMAA topic). The only viable solution I know of right now is supersampling but it's quite expensive...
     
  35. Jack-Cloud

    Jack-Cloud

    Joined:
    Dec 4, 2014
    Posts:
    1
     
  36. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    I don't understand why we still don't have a good solution for AA in Unity (except the SSAA), since we are supposed to make great AAA game...Edit: Like temporal AA (used in Unreal).
     
    Last edited: Aug 14, 2015
  37. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Potential fix : select the noise texture (/SSAO Pro/Resources/noise) in the project panel and set the filter mode to Point instead of Bilinear. Let me know how it works for you (thanks to Michael Thomas) !
     
  38. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,066
    Aras said this in Feb 2015:

    We have people looking into proper "built-in" temporal postprocessing AA solutions here, but that will be post-5.0.​
     
  39. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Indeed.. :rolleyes:
     
  40. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Because good realtime AA isn't easy (except, once again, SSAA but it's very expensive). Unreal's temporal AA isn't magic, far from it. It's a correct implementation but it's not perfect. Try it & browse their forums, you'll find out people over there also ask for "better AA".
     
  41. cAyouMontreal

    cAyouMontreal

    Joined:
    Jun 30, 2011
    Posts:
    303
    AA was always a problem since we got 3d games, Unreal's solution might not be perfect, but it still far better than Unity provides right now. Temporal from this post: http://forum.unity3d.com/threads/temporal-anti-aliasing.312525/ is quite blurry but it provides far better specular AA.
     
  42. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    To get better specular AA what you do is do actual specular AA!
    One good way is to use the Toskvig solution, it doesn't "solve" it fully, but it does make uneven things be rough instead of glossy when zoomed out, generally more correct and gets rid of a lot of the specular aliasing issues!
    http://blog.selfshadow.com/2011/07/22/specular-showdown/
     
  43. FranckS

    FranckS

    Joined:
    Jan 14, 2014
    Posts:
    29
    Yep it does work. Thanks :)
     
  44. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Update time !

    Changelog (1.6) :
    • Removed: "1.1 (Legacy)" mode.
    • Added: Unity 5.1+ users, you can click the top-right help button on the SSAO Pro components at any time to jump to the documentation.
    • Fixed: Sample precision issue in the distance.
    • Fixed: ATI driver bug (the infamous "dot pattern").
    • Fixed: Compilation error on PS4.
    • Misc: Brand new documentation and website.
     
    overthere and GoGoGadget like this.
  45. pan567

    pan567

    Joined:
    Aug 8, 2015
    Posts:
    7
  46. pan567

    pan567

    Joined:
    Aug 8, 2015
    Posts:
    7
    You seem to be very good with ambient occlussion.I'm sure if you include all the features from SSAO Pro to DSSDO
    you'll be a millionaire in like 2 seconds.
     
  47. pan567

    pan567

    Joined:
    Aug 8, 2015
    Posts:
    7
    you could use poisson disk samples for better quality-performance ratio.
     
  48. pan567

    pan567

    Joined:
    Aug 8, 2015
    Posts:
    7
    I'm not sure if this is possible, but instead of poisson disk samples you could sample the scene using the golden ratio fibonacci dot pattern as seen below:

    vs poisson disk sampling:
    upload_2015-10-11_13-5-17.png
    you can clearly see a more regular pattern.
     

    Attached Files:

  49. alllen

    alllen

    Joined:
    Aug 14, 2012
    Posts:
    12
  50. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I don't have any plan to implement SSDO in SSAO Pro at the moment as it would require a massive rewrite of the codebase. On the other hand, I've been meaning to look into better sampling strategies (i.e. poisson).
    In the Project panel, go to /SSAO Pro/Resources/, right click on SSAOPro.cginc and Reimport. That should fix it (at least according to the errors you're getting).
     
unityunity