Search Unity

  1. Unity 2019.4 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  3. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

SSAO Pro - High Quality Screen-Space Ambient Occlusion

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

  1. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    @RodneyO
    Maybe it's the time for open a thread on this forum.
     
    boysenberry likes this.
  2. RodneyO

    RodneyO

    Joined:
    Jan 22, 2011
    Posts:
    50
    thanks for the suggestion ZJP. I have one up now.

    I think i now know why that stuff wasn't drawing properly. I think SSAO uses depth to figure its stuff out (correct me if I'm wrong Chman)

    Unoshader doesnt use this tag Lightmode = "shadowcaster" unless you turn shadows on. This tag also helps figure out depth without it SSAO breaks.

    So Dan the fix attached earlier works but now all unoshaders are trying to calculate shadows which is generating an extra 2 drawcalls per object (not good) Roll back to the original file and just turn on shadows on the objects that will be in combination with SSAO. Does that make sense?
     
    ZJP likes this.
  3. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    You're right, it uses depth & normals, and after further investigations it turns out Unity 5 makes use of the ShadowCaster pass to compute the depth (whereas Unity 4 used a replacement shader) :)
     
  4. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,197
    @Chman I was wondering is it possible to show the AO only on specific gameobjects, or is it all or nothing? The reason being is that for the project I'm currently working on they want a tour of a building with the AO effect on, everything white with black outline/shadow, but they'd like for a few objects within the building to be highlighted red. Is this possible with the SSAO plugin?
     
  5. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Not really, no, there isn't any easy and cheap way to exclude (or include-only) objects from the AO pass because of the depth & normals buffers. In your case you could simply use a pure white (unlit) material for the building, this way you would get the same effect as showing the AO-only pass for the selected objects. Unless I misunderstood what you're trying to achieve.
     
  6. Ben-BearFish

    Ben-BearFish

    Joined:
    Sep 6, 2011
    Posts:
    1,197
    You understood my question correctly. In Unity 5, is it better to use the legacy unlit shader, or try to use the standard shader?
     
  7. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    With Unity 4 you could simply use the Unlit/Color shader, the problem is Unity 5 has changed the way it generates the depth buffer... It now relies on the ShadowCaster pass, which is non-existent on unlit shaders for obvious reasons.

    So you either have to fiddle with the Standard shader or write a custom unlit shader. The easiest way would be to use the Standard shader and set the Emission to 1 & pure-white. That way you'll get a (fake) pure-white material and the AO would still be applied to it.
     
    Ben-BearFish likes this.
  8. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Doesn't this asset support soft particles? Soft-particles setting is ignored when I turn this effect on.
     
  9. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I can't reproduce this bug (Forward & Deferred) in Unity 5, soft particles work fine with SSAO here. What version are you working with ?
     
  10. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Thanks for reply, I use 4.6 with deferred rendering, linear color space.
    If I disable SSAOPro on inspector, soft-particles properly work.
     
  11. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Ok, it's an issue with the High Precision Depth Map (which you only really need when working in Forward in Unity 4.x). Disable it, it'll work. If you want it to be enabled anyway, go into the SSAOPro.cs file, lines 353-358 :
    Code (CSharp):
    1. #if UNITY_4_X
    2.         if (!UseHighPrecisionDepthMap)
    3.             m_Camera.depthTextureMode |= DepthTextureMode.Depth;
    4. #else
    5.         m_Camera.depthTextureMode |= DepthTextureMode.Depth;
    6. #endif
    Replace all this lines by :
    Code (CSharp):
    1. m_Camera.depthTextureMode |= DepthTextureMode.Depth;
    It'll be fixed in the next patch.
     
  12. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Hi,
    Is it possible to display the 'SSAO (black and white) with objects (placed in a layer) that would keep the 'colors'. I mean detach characters from the black and white background 'ssao'. A sort of 'Highlight'.

    Désolé si mon Anglais est confus. Je pense à une option qui permettrait d'isoler les/des personnages (par exemple) dans un rendu ou l'on afficherait le SSAO de la scène.

    Exemple : les tonneaux au sol sur cette image conserverait leurs "couleurs".
     
  13. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Without replacing materials, no. The easy way would be to apply a pure white material to every object that shouldn't be "colored", like explained in this post. For example in the screenshot, you would set a pure white material for everything except the barrels.
     
  14. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Thanks for the reply. :cool:

    Désolé, je n'avais pas vu la réponse au dessus. Ma demande est une pure coïncidence.
     
  15. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    UseHighPrecisionDepthMap-off makes an error occurred in "Graphics.Blit", so I edited the source code and it works!
    Thanks!:)
     
  16. Michael-Thomas

    Michael-Thomas

    Joined:
    Jul 8, 2014
    Posts:
    20
    Regarding the Radeon grid-of-dots bug. Am I correct that that's still known to be happening in the latest version of SSAO Pro (I just updated and still see it on a Radeon card)? Also, as a data point, it looks to me like it ONLY occurs when Downsampling != 1. It also appears it only happens on the part of the screen nearer than Max Distance, which is perhaps not surprising.
     
  17. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yeah there's a weird AMD/ATI driver issue with downsampling (when using Unity's Graphics.Blit() on variable sized render textures). Sometimes it's a grid-of-dots, sometimes it's working but half the screen is reversed (wth!?).

    And, like you said, something's not right with the depth buffer precision on these cards. I'm still trying to figure out what's happening but it's not easy without a dedicated AMD GPU to test on.
     
  18. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    Two more questions:

    1. When I don't use HighPrecisionDepthMap in Unity 4.6, following error is occured: "Invalid pass number for Graphics.Blit" at SSAOPro.cs line 320. ( line 375 change causes an error ) Also it says "Shader error in 'Hidden/SSAO Pro V2': Can't open include file "SSAOPro.cginc" at line 130, 164" but I don't know it's related to this error. How I can off HighPrecisionDepthMap?

    2. I noticed SSAO Pro doubles Draw Calls in my scene; as if static batching is not worked. Does it cause a strike on my game performance?
     
  19. anarcheril

    anarcheril

    Joined:
    Jan 8, 2013
    Posts:
    21
    Hey there, I'm just having some flickering issues with SSAO Pro on grass for terrain, occasionally it will just ignore grass. I've done some rudimentary searching but I can't seem to solve this issue http://puu.sh/hT8bt/1055187337.png . My max distance is 150 and my falloff is 50.
     
  20. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Did you moved SSAO Pro to a subfolder ? That's an annoying Unity 4.x bug with shader includes... Open /SSAO Pro/Resources/SSAOPro.cginc and add a space at the end of the file, save it, it will force a refresh from Unity. You may need to do the same with the SSAOPro_v1 and SSAOPro_v2 files.

    That's because of the High Precision Depth Map, it renders most of the scene a second time. Only use it if you work with Unity 4 in Forward and experience a loss of quality. Else you don't need it.

    Is this Unity 4 or 5 ? Default grass on terrain or a custom grass shader ?
     
    alexzzzz likes this.
  21. anarcheril

    anarcheril

    Joined:
    Jan 8, 2013
    Posts:
    21
    It's Unity 5, currently the custom grass shader on terrain. That will probably be changing in the future (the terrain system), so if you think that will solve the issue I can wait until then.

    Edit: This appears to definitely be an issue with grass in unity 5 as shadows will occasionally be drawn through the grass (on objects through the grass) in the same problematic areas for the SSAO. Great job on the SSAO btw, it's exactly what I needed for my stylized game.
     
    Last edited: May 19, 2015
  22. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yep a few others noticed grass shadows flickering too (without SSAO). And the shadow pass being used to generate the depth texture by Unity, it doesn't surprise me it makes the SSAO flicker as well. We'll see if Unity 5.1 fixes it.
     
  23. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,727
    Why would 5.1 fix it?
     
  24. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Because flickering shadows is a Unity bug ?
     
  25. okumasama

    okumasama

    Joined:
    Jun 17, 2014
    Posts:
    16
    >Did you moved SSAO Pro to a subfolder ?
    Exactly I was. I refreshed source files and both questions are cleared.
    Thanks for rapid reply and great works!
     
  26. fuzzywobs1

    fuzzywobs1

    Joined:
    Feb 28, 2015
    Posts:
    6
    Following the previous comments about incompatibility with the Oculus Rift, has there been any changes on that? Is it still not suitable for VR?
     
  27. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Since 1.2 there's been a few important changes and it's more stable. 1.5 is coming very soon as well with a bunch of enhancements. Now, how that translates to the OR, I'm not sure. I don't have one unfortunately so it's hard to say.
     
  28. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Update available :)

    Changelog (1.5) :
    • Added : New blur filter, "High Quality Bilateral". Smoother, more stable than the older "Bilateral" and with a lot less pattern artifacts (performances should be very close to the old blur).
    • Added : Optional multi-pass blur (all filters).
    • Fixed : Soft Particles not working correctly when the High Precision Depth Buffer is enabled (Unity 4.x).
    • Fixed : A few bugs with the startup screen.
    • Fixed : Minor compilation bug on PS4.
    • Fixed : Tiny bug with the older "Bilateral" blur filter.
    • Removed the documentation from the package, it's now online only. Benefits : the package size is a smaller and imports faster.
     
  29. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    Hello Chman,

    I apologize in advance for my bad English I'm French!

    Firstly your plugin is just huge and treatment is beautiful!

    I come to you because I have a problem I can not solve despite my settings and paths in the forums about this.

    I made a screen capture of my problem so that you can understand.
    I have a "flag" that I wish to animate (cloth) which is simply a plan created in 3ds max with his bones.
    I can not apply in my case two planes with normals reversed since the goal is to make it float with the wind and if I make two planes they will never synchronized in their animation. A shell on the model does not fix the problem either.

    My only solution seems to me so it is to make a plan simply.


    I will accompany my screen capture with a v ideo to support my problem: http://izegames.com/prob/normals_SSAO-pro.mp4

    I actually uses Shader Forge but I tried with any shader I get the same rendering. In the video I present the same problems with a standard shader Unity5

    I know that these are the normals that cause this problem but I look for a solution in my situation

    Thank you for the time you will grant me

    Best regard
    Jimmy B.
     
  30. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Comme lui... :p
     
    2pass likes this.
  31. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The good solution would be to create a custom double-sided shader (2 passes, one for each side). I'm not sure how you would do that with Shader Forge.

    There's another (easier) solution : setting the shader culling to double sided. This won't be perfect but in your case it will probably work just fine. I don't own Shader Forge, but according to its documentation you can set this on your shader in the left panel : Blending & Depth -> Face Culling -> Double Sided.
     
    2pass likes this.
  32. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    Hello Chman,

    Have you had this working with two camera splitscreen with ssao on each camera? (deferred on each)

    It keeps crashing unity 5.1. the same happens with Unity's version too.
     
  33. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    Hi Chman,

    For your answer!
    I'm going in your direction, and unfortunately I did not find the solution because I use most of the opportunities you offer.

    Here are below the configuration in 3ds max my shader:


    Here is the shader forge configuration (I nétoyé everything else and let the texture):


    I still got a good result by doing this: Custom blendmode / Minus One Alpha Dst

    The big problem with this setup is that I no longer received the shadows


    Hoping that you will find a solution thanks to new settings and images.

    For other if the shadow on your reception elements is not an obligation, and my settings image2 work well!

    Thank you in advance
    2pass
     
  34. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Unity 5.1 isn't final yet but I just tried it and it works for me so I'm not sure what's going on (5.1.0f2, split screen deferred, Win 7 x64). What's the crash you're getting ? The fact that the default AO doesn't work either hints at a Unity bug or a hardware incompatibility.
    Hmm just did a few tests. The Cull Off method only seems to work in Deferred. I guess you're working with the Forward rendering path ? So yeah I'm not sure if there's a good way around that unfortunately. That would be one more reason not to use 2-sided materials...

    You second shader (custom blending) will not receive AO because it's not opaque (transparent objects aren't written to the depth buffer).
     
  35. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    I do not understand this question:
    I use well CullOff:
     
  36. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    What Rendering Path is your camera set to ? Deferred or Forward ?
     
  37. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    ^^ I understood now the camera is on Forward!
     
  38. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    So, like I said in my previous post, in this case Cull Off will only work in Deferred. And obviously your shader being transparent won't help either as it will be skipped by the AO pass. I'm not sure if there's an easy solution to your double-sided problem unfortunately...
     
    2pass likes this.
  39. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    I do not need my shader is transparent. I can very well do the same with an opaque shader its not working either.

    I tried with Deferred and its not working anyway!
     
  40. TechiTech

    TechiTech

    Joined:
    Dec 13, 2014
    Posts:
    212
    after many hours of stress, I now no never to have a 3d object with no material in my scene. That was causing the game to crash when playing in build. I never knew something so small could cause this much problems.

    Do you think I should submit a bug report? or is that expected.
     
  41. 2pass

    2pass

    Joined:
    Dec 7, 2014
    Posts:
    12
    Chman,

    I you're sent to my private message szene history to save time in our exchanges.

    Thank you in advance of the time you will give
     
  42. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,126
    IMO, it wouldn't hurt to submit it. Stuff like that could be detected and handled better, at the very least. Right?
     
    Chman likes this.
  43. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
    Unity 5.1.0f3 Pro

    Updated SSAO Pro to 1.5. We're using deferred rendering path.

    Invalid pass number (6) for Graphics.Blit. Material=Hidden/SSAO Pro V2, npasses=1
    UnityEngine.Graphics:Blit(Texture, RenderTexture, Material, Int32)
    SSAOPro:OnRenderImage(RenderTexture, RenderTexture) (at Assets/Third Party/SSAO Pro/Scripts/SSAOPro.cs:339)

    Tried forcing UseHighPrecisionDepthMap, but had no effect.
     
  44. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    This option isn't in Unity 5. Was your project migrated from Unity 4 to Unity 5 at some point ? Because the package for SSAO Pro isn't the same in Unity 4 and Unity 5. So you might probably need to remove SSAO Pro from your project folder, go to the asset store and download the package from Unity 5.x and re-import it.
     
  45. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
    Deleted the old copy, pulled a fresh version, works now. Thanks.

    Correction: now when I restart Unity, receive the following warning and the component is disabled on the camera:

    Unsupported shader (SSAO).
    UnityEngine.Debug:LogWarning(Object)
    SSAOPro:Start() (at Assets/SSAO Pro/Scripts/SSAOPro.cs:188)

    Tried deleting and downloading again. Receive the API Update Required dialog again. Works. Save scene and restart Unity. Ok, seems to have calmed down now and is working. Perhaps doesn't like be relocated out of the root to another folder.
     
    Last edited: Jun 18, 2015
    Chman likes this.
  46. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Well, you can move the asset to a sub folder but in some cases you'll have to refresh the *.cginc files because Unity doesn't, which causes the shader compilation to fail. The easiest way to do that is simply to open the file, add a space at the end of it and save it.

    It's quite annoying :/
     
  47. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hotfix available !

    Changelog (1.5.1) :
    • Fixed : Compilation issue when upgrading to Unity 5.1 from an earlier Unity version (UnityEditor API change).
    • Fixed : A few warnings on DirectX 11.
     
  48. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    820
    Is there any way to get this to work with a two camera setup and deferred lighting? Love how it makes our game look, but I can't seem to get it to play nicely with our camera setup (required for our dynamic weather system).

    MainCamera - depth 30, clear flags: don't clear or depth only, this is the camera I'd like to use SSAO on
    CloudCamera - depth 1, clear flags: skybox, this camera breaks if I have SSAO on MainCamera.

    SSAOOn.png SSAOOff.png
     
  49. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I'm not sure how I'm supposed to interpret your screenshots.

    Because you're working with Deferred Lighting, I'm going to guess this is an Unity 4.x project ? Let me see if I understand : you want your Cloud Camera to render, then Main Camera on top of it and apply SSAO Pro to that Main Camera ? I just did a quick test in Unity 4 and it works as expected, SSAO Pro is applied to objects rendered by the Main Camera and objects from Cloud Camera are unaffected.

    Or did I misunderstand you ?
     
  50. KyleStaves

    KyleStaves

    Joined:
    Nov 4, 2009
    Posts:
    820
    5.0 actually, but I was mistaken - turns out I am using forward rendering. Enabling SSAO has the effect of making the scene look as though the cloud camera simply doesn't exist (so anything not covered by the main camera doesn't clear, which is why you see repeats of the terrain instead of the sky).

    EDIT:
    http://forum.unity3d.com/threads/grabpass-problems-when-using-multiple-cameras.167676/

    Looks like it's a pretty known issue, tried all of the discussed work arounds in that thread and another but no luck so far. Certainly not an issue with your SSAO asset, I was just hoping you'd run into a solution before (the Unity SSAO causes the same problem).
     
    Last edited: Jun 26, 2015
unityunity