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

SSAO Pro - High Quality Screen-Space Ambient Occlusion

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

  1. alllen

    alllen

    Joined:
    Aug 14, 2012
    Posts:
    14
    Tried that, doesn't work. I tried removing SSAO Pro from the project entirely. Closing it, then readding it to the project. Breaks as soon as I build, but will work until then. After that it breaks completely no matter if I reimport, I'd have to complete delete the files and then re-open Unity again for it to work. And then it would just break again when I build. Rinse and repeat.
     
  2. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    @alllen I'm not able to reproduce it (using 5.2.1f1 and DX11). I can build, rebuild, close, re-open fine. The way you describe it, it sounds like a bug with the UnityShaderCompiler process. I have a lot of issues with it myself since Unity 5.1 (crashes, random errors that force me to restart Unity etc) but not related to SSAO Pro. It seems to be a general issue.

    Could you maybe try in a new empty project, see how it works ?
     
    Last edited: Oct 12, 2015
  3. alllen

    alllen

    Joined:
    Aug 14, 2012
    Posts:
    14
    Empty new project there seems to be no issues at all, works just like it should. How frustrating, seems like it's a problem on Unity's end and not your asset's.

    edit: I deleted the library folder and updated to 5.2.1p3 and the issue seems to have fixed itself. Not sure which action fixed what but it seems to be resolved now. Some weird Unity thing, I guess..Hope that's the end of that!
     
    Last edited: Oct 12, 2015
  4. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's unfortunate :(
    If your project isn't too big, maybe you could send a bug report to Unity ?
     
  5. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
  6. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    141
    Just got it and having a lot of fun.
    As a suggestion, it would be amazing if some objects/layers could be excluded. For instance those ones that have AO backed already.
    Cheers.
     
  7. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's a commonly requested feature but unfortunately, because of the dependency on the depth & normal buffers it's not something that can be done easily / efficiently. The workaround is to use a multi-camera setup but if you work with the Deferred rendering path (the recommended one for SSAO Pro) you'll run into a Unity bug...
     
  8. Quique-Martinez

    Quique-Martinez

    Joined:
    Oct 1, 2013
    Posts:
    141
    I see. Thanks anyways.
    I don't know the technical details (actually I'm totally naive about shaders), so this idea might sound stupid:
    Do you actually generate that black and white image and overlay it over the camera view? In such case it shouldn't be difficult to generate another white one containing the excluded layers and blend with the AO before aplying it.
    I did a dirty test in Gimp, blending the AO over the image after excluding the cube.
    Sorry if the idea was terrible.
    1.png 2.png 3.png
     
  9. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It's not that simple. First of all, generating a mask means rendering the scene a second time and can be tricky (the draw call count will go up and performances will suffer, quite a lot in some cases). Then, because ambient occlusion isn't restricted to the object boundaries you'll be left with small shadows and AO samples generated outside of this object because it's present in the depth & normal buffers, it will look wrong. The object itself will actually cast AO and contribute to neighbor objects AO even if you mask it out afterwards, that's unavoidable.

    AFAIK the only way to do proper AO masking is to render the scene without the excluded objects (so that the depth & normal buffers are properly populated), apply the AO and then composite the excluded objects back in... And this is exactly what a multi-camera setup would do in Unity.
     
  10. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,246
    ssao.jpg
    I'm having trouble making SSAO Pro (right in image with med-high setting) as soft and smooth as the built in Unity 5 SSAO (left). In particular there is noticable banding and some whiteness on the edges of objects. Ultra settings make little difference
     
  11. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The banding is due to the way samples are distributed right now, but it shouldn't be noticeable unless you really zoom on an occluded area. I choose this method because it helps making the AO look stable when the camera moves (so you don't see samples jittering around) and reacts better to small hard-surface details (small creases etc). Generally speaking, that's not something you'll notice in a textured environment. I assume in this case you zoomed all the way to a small object ? FWIW, I'm working on a alternative sample distribution method to reduce banding in these cases and get a nicer look in VR.

    The white edges you can see sometimes are a side effect of the high-quality bilateral blur filter. That's something I've been meaning to look into.
     
  12. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,246
    Ok well it's a cropped shot but I am working on quite plain/pale scenes at the moment so these things are much more obvious, even uncropped.
    I agree SSAO Pro is better with finer details but a smoother look when required would definitely be good.
     
  13. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,246
    If I use the stencil buffer to cutout windows in some polys the SSAO effect does not work behind the window plane, perhaps because the depth pass is using a different shader. DO you know how I fix that?
     
  14. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's a tricky one, it's not related to SSAO Pro per say but to the way Unity generates the depth & normal buffers.

    In this case, you're not seeing any AO applied behind the window plane because no depth & normal info is generated there (or, to be exact, you'll get depth & normal data from the wall itself, not what's behind it). You'll probably have to edit the Camera-DepthNormal replacement shader (it should be in the builtin-shaders archive) to include your stencil-enabled shader. It should work in theory but I haven't tested it with the stencil buffer.
     
  15. Stone-Legion

    Stone-Legion

    Joined:
    Aug 16, 2013
    Posts:
    112
    What is the advantage of this over the built in SSAO that unity ships with in Unity 5? Aside from the slightly faster processing times.
     
    ZoneOfTanks likes this.
  16. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    You should take a look at the newest reviews to read why people chose SSAO Pro instead of the default one :) For some it's the better performances, for others it's the overall better render quality, less artifacts, more settings to customize...
     
  17. HoMeBoYErik

    HoMeBoYErik

    Joined:
    Mar 12, 2014
    Posts:
    23
    Hello, I'm using it with Oculus and it's very nice. How do you enable/disable it at runtime?
    If I disable the component SSAO Pro on the camera, the camera stops rendering.
     
  18. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hello,

    Well, you could set the Intensity to 0 but disabling the component shouldn't stop the camera from rendering at all. It doesn't do anything when disabled so I'm not sure why you're getting this issue. Does it only happen with SSAO Pro ? Have you tried with other image effects ? Does it also happen in the demo scene (with and without VR) ?
     
  19. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Hi Chman, I've loved adding SSAO pro to my scene, a million times better than the built in SSAO.

    I'm having some trouble however with transparency. I have a GameObject that is Initiated with the Standard shader set to Transparent render mode and I have it fade in. Once it's faded in I use the following code to switch it to opaque:

    Code (CSharp):
    1. Material mat = renderer.material;
    2. mat.SetFloat ("_Mode", 0);
    3. mat.SetInt ("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);
    4. mat.SetInt ("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
    5. mat.SetInt ("_ZWrite", 1);
    6. mat.DisableKeyword ("_ALPHATEST_ON");
    7. mat.DisableKeyword ("_ALPHABLEND_ON");
    8. mat.DisableKeyword ("_ALPHAPREMULTIPLY_ON");
    9. mat.renderQueue = -1;
    But for some reason I can still see certain artefacts coming through from the scene behind the object. This a) only happens in forward rendering and b) only happens when SSAO pro is enabled. Turning it off or switching to deferred stops it. Weirdly if I manually edit the material in the editor (switch it to Transparent and back) it fixes it? Unfortunately I can't use deferred for other reasons. Any ideas?
     
  20. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Ah found it. This must be new, add this after SetFloat("_Mode", 0);

    Code (CSharp):
    1. mat.SetOverrideTag("RenderType","");
     
  21. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hey ! I was about to answer with the same piece of code but you posted first :)

    A better way would be to use the static method SetupMaterialWithBlendMode(material, blendMode) in StandardShaderGUI instead, it would ensure its compatibility with future versions in case the Standard shader changes ;)
     
  22. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Any idea how to call it? It's (StandardShaderGUI) unrecognised for me? Do I have to import something?
     
  23. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Huh you're right. It's an internal class and it's in the UnityEditor namespace anyway so you can't really use it at runtime... Nevermind :)
     
  24. ph0b0s

    ph0b0s

    Joined:
    Dec 18, 2013
    Posts:
    19
    Hi, this plugins is amazing but i´m having problems now with transparentCutout shaders and what is seems to be the add shadow pass. I have made a dissolve shader and when it´s value is 1 (full dissolved) the SSAO is painting a weird black mesh where the object is (but full occluded by the cutout). If I change the shader to a standar one with cutout all seems to work well but if i make a custom shader from a surface shader, when i include the "addshadow" pragma then this artifacts appear. This happens also with all that isnt the build-in standar shader (SF shaders or custom shaders made from the default one dont work for me).
    Can u tell me if i need to change something? I really want to use this plugin in our project but we use transparent cutout shaders in almost all the objects here because of this dissolve animations.
     

    Attached Files:

  25. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    A few things can be happening in this case, but you most likely need to add your custom dissolve / cutout shader to the Camera-DepthNormal replacement shader (look in the Built in shaders archive) so that it will write the correct depth & normal values that SSAO Pro and a few other effects use behind the scenes.
     
  26. ph0b0s

    ph0b0s

    Joined:
    Dec 18, 2013
    Posts:
    19
    But my shader is using the rendertype "TransparentCutout" and this seems to be included in the build-in shader. By the way ,how i would change that hidden shader to use it? Many thanks in advance.
     
  27. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Well, how you'd do that depends on what you're doing in your shader exactly. Could you maybe send me the shader by PM or something ? I can take a look :)
     
  28. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    So what's the preferred setup for multiple cameras? Combine them first and then apply SSAO? Apply individually to each camera? How would that impact performance? Does forward/deferred make a difference?
     
    Last edited: Nov 4, 2015
  29. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I̶f̶ ̶S̶S̶A̶O̶ ̶P̶r̶o̶ ̶i̶s̶ ̶u̶s̶e̶d̶ ̶o̶n̶ ̶t̶h̶e̶ ̶l̶a̶s̶t̶ ̶c̶a̶m̶e̶r̶a̶ ̶t̶h̶e̶n̶ ̶i̶t̶ ̶s̶h̶o̶u̶l̶d̶ ̶j̶u̶s̶t̶ ̶w̶o̶r̶k̶,̶ ̶a̶s̶s̶u̶m̶i̶n̶g̶ ̶y̶o̶u̶'̶r̶e̶ ̶n̶o̶t̶ ̶c̶l̶e̶a̶r̶i̶n̶g̶ ̶t̶h̶e̶ ̶d̶e̶p̶t̶h̶ ̶b̶u̶f̶f̶e̶r̶.̶

    If it's not on the last camera it depends on your rendering path. In Forward it works out of the box, no need for a special setup. Using Deferred... Because of this bug in Unity the only viable solution I could find is to render your cameras one by one in a global RenderTexture (see this post) :|
     
    Last edited: Nov 5, 2015
  30. J_P_

    J_P_

    Joined:
    Jan 9, 2010
    Posts:
    1,027
    "Last camera" would be the one with the highest depth?

    Unity 5.2.2f1, SSAO Pro 1.6. Was experiencing weird behavior in my project so I'm testing in a fresh project.

    Have two cameras -- MainCam (depth -1) clear flag set to skybox, renders everything but View layer. ViewCam (depth 0) Clear Flag set to depth only, renders only View layer.

    Putting SSAO Pro on either camera only affects that specific camera. Does setting ViewCam's clear flags to depth only clear the depth buffer? I assumed that's the main way people use multi camera setups.


    (only enabled on ViewCam)

    Am I misunderstanding something?
     
  31. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yep !
    It clears the depth buffer so that objects are rendered "on top" of the previous rendered camera (lower depth). So you'll only get AO on whatever's rendered by this camera (unless using Deferred, then it will only work on the top most camera because it's broken).

    Sooo it looks like my previous post was partly wrong. It's weird, because I remember getting it to work correctly in Unity 4... So if you want objects from ViewCam to cast AO on MainCam the only way seems to be to composite the render yourself but I'm not even sure it's possible because of the way depth is handled with multiple cameras.
     
  32. StormlordGames

    StormlordGames

    Joined:
    Nov 30, 2013
    Posts:
    10
    Hello!
    First off I want to say that i love the program. It makes my game shine.

    I do have a question about distortion shaders - when I apply Effects/Distortion/ParticlesCutOut material to an emitter the particles do not honor the alpha/cutout completely. Each spawned particle has a faded black element where it should be invisible. When I remove SSAO pro the effect looks fine - alpha/cutout working properly no faded black elements.

    Here is an example of what I am seeing with SSAO pro turned on:



    The red circles outline the faded black elements which are the flat cards as they are spawned. The distortion effect works but the black elements ruin the effect.

    Any suggestions?
     

    Attached Files:

  33. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It's most likely a render queue issue or the shader not being setup correctly in regard to depth writing. Where did you get this "Effects/Distortion/ParticlesCutOut" shader ? I can't find it in the standard assets...
     
  34. SimoneDunzendorfer

    SimoneDunzendorfer

    Joined:
    Jun 23, 2015
    Posts:
    35
    Can it be used for realtime or is it more for like cut scenes?
     
  35. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It can be used in realtime on desktop and console platforms (not on mobiles).
     
  36. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Is folder of this asset movable? I have big project with finished folder structure and I need it to be movable to custom path ;) Also a question - is this asset really better than standard Unity 5.2.2 SSAO? I mean is difference really visible?
     
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's faster, more tweakable, and thus better.
     
  38. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,624
    It's way faster.

    I generally don't like SSAO filters. I think they are like bloom in the 2000s, they are very overused. I only use them with low intensity values so they are more subtle. But the built in filter is rather slow, so it was not worth it. Now I'm adding SSAO Pro everywhere :)
     
  39. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yes, you can move the folder :) In some rare occasions you may get a compilation error from the shader after it's been moved (something about a missing SSAOPro.cginc even though it's here). To fix it, right click /SSAO Pro/Resources/SSAOPro.cginc then Reimport.
     
  40. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    @Chman: I seem to have found an issue with using SSAO Pro in combination with orthographic camera projection. I may or may not have found a bug that causes the number of SetPass calls to explode and I'm having trouble determining under which exact circumstances it does it. But it seems harder to reproduce it not doing it than getting the high number of SetPass calls.

    Please see these 2 screenshots for comparison of my testcase:



    I have imported the ssao pro files straight from the assetstore window. I'm still using Unity 5.2.1f1

    What I find especially weird is that if I have the play mode running and I switch the cam from ortho to perspective the SetPass calls go back to normal, but if I leave it at ortho and remove the SSAO Pro component from the camera (still in play mode) the SetPass calls stay high, even after switching back and forth between perspective and ortho. I'm really confused what is going on there.
     
  41. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It probably has to do with the fact that SSAO Pro makes use of the depth and normal buffers which, as far as I know, aren't generated properly in ortho mode. An easy way to check is to try the same thing using the default SSAO effect that comes with Unity (Standard Effect package). Could you try it ? I'm currently moving accross the country so I won't have access to my computer and a proper internet connection until next week (at best).
     
  42. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Thanks for the quick reply! I think you are spot on. Same behaviour with the default SSAO effect and I now noticed that the massive increase in drawcalls correlates with the text on the camera component changing from "info: renders depth texture" to "info: renders depth & depthnormals textures". If the ortho camera causes problems here I wouldn't be surprised if I'd get problems down the line with other components as well. I'll re-evaluate if I really need the ortho camera or if I could use a very narrow FOV instead with the perspective camera.

    Good luck with your move! I've moved to another city a few months ago and moving accross the country must be so much more stressful. I hope all goes well, enjoy your new home!
     
  43. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    I'm getting very bad performance with Unity 5.3. Profiler reports huge Overhead when SSAO Pro is enabled. Absolutely fine in 5.2.

    Funnily enough I get a similar lag and spike in Overhead when Tilt shift (built in Image effect) is enabled and set to High Quality. Perhaps it shares a similar Graphics API call?
     
  44. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hmm that's unexpected. What's your target API ? DX9/DX11/GL ?
     
  45. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Runs fine under 5.3 for me. Didn't notice any difference.
     
  46. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Hmm struggling to reproduce with a completely new project. I can reproduce it in the Unity 5 Shooter sample project from the asset store - although that has some other weird problem, the camera completely breaks with SSAO Pro enabled. The Overhead is visible.

    > What's your target API ? DX9/DX11/GL ?

    It's set to Auto Graphics API
     
  47. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I can't seem to be able to reproduce it with DX9 / DX11 / DX12 experimental / GL2 / GLCore on windows, so honestly I'm not sure where to look... If you're profiling in the editor, keep in mind that it's not the best way to test for performances as the editor itself can add a lot of overhead (in some projects more than others for some reason).
     
    Martin_H likes this.
  48. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Hmm ah, i'm on OSX, El Capitan. I have the same problem with the standalone OSX Builds. The Unity 5 Shooter project works ok for you with SSAO enabled? I will try to find some reliable steps to reproduce it.
     
  49. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    By Unity 5 Shooter project you mean this one ? It's running slower than it should indeed... It comes from the fact that the camera is in orthographic mode, when switching to perspective everything runs great again. I'm not sure what changed in 5.3 to make the ortho mode so slow, I just tried it in 5.1 and it's running fine there... I don't see anything of note in the 5.3 changelog. I'll investigate.

    But you should note that I don't recommend using ssao or any kind of depth-based effect in ortho mode as it won't look correct anyway (the depth map doesn't look correct because orthographic projection is a weird case and doesn't have any depth per say).
     
  50. aaronjbaptiste

    aaronjbaptiste

    Joined:
    Dec 4, 2012
    Posts:
    62
    Yep that's the one. Ah right, maybe the Shooter project has a different problem then. My personal project has a Perspective camera with a FOV of 20 and set to Deferred rendering.

    I will delete/reset everything from my project systematically until I have located exactly what the cause is and package it up.

    As I said I have a very similar problem with Tilt shift, I deleted everything from my upgraded project, including resetting the Player and Quality settings and leaving just the Camera in an empty scene and still have bizzare overhead when tilt shift was set to High Quality. Creating a new project from scratch and setting the scene up to be same the had no issue. I've reported it to Unity, nothing heard back so far.