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
    Yeah that's definitely strange. Let me know if you can get to the bottom of this and find the exact cause, I'm interested. And maybe I'll be able to find a workaround for SSAO Pro as well.
     
  2. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    Is there a reason why the depth buffer would not work correctly in Legacy Deferred render mode with this image effect? It works fine in Deferred, but I have other assets that require Legacy Deferred.
     
  3. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It should work fine with the legacy deferred rendering path. That's the one I actually recommend when working with Unity 4.x and I see no reason why it would fail in Unity 5. Are you experiencing something wrong with it ?
     
  4. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    Yes, I was having trouble identifying the problem earlier today when I took to twitter and posted this gif. I went through my image effects one by one and found that the SSAO Pro image effect was the cause of the shading issue. When I use the "Show AO" button in the inspector I see large, strangely shaded polygon faces that change according to view angle on all geometry in the scene other than my terrain (I am using the RTP terrain shader which works best with Legacy Deferred).

    EDIT: I'm not sure what happened, but the issue appears to be gone now. I will report if I find any more anomalies.
     
    Last edited: Dec 16, 2015
  5. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's a new one... It looks more like a normal buffer issue to me. I'm glad (?) it fixed itself, let me know if you're able to reproduce it or if it comes back.
     
  6. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    Please help! I get the following errors with SSAO Pro:

    "Assets/SSAO Pro/Scripts/SSAOPro.cs(14,2): error CS0246: The type or namespace name `HelpURL' could not be found. Are you missing a using directive or an assembly reference?"

    "Assets/SSAO Pro/Scripts/SSAOPro.cs(14,2): error CS0246: The type or namespace name `HelpURLAttribute' could not be found. Are you missing a using directive or an assembly reference?"

    I use Unity 4.7.
     
  7. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Gah. That's because the version number changed and 4.7 uses a new platform define... SSAO Pro checks the current Unity version to enable/disable features. As I didn't expect to see Unity 4 get a new release number (except for patches and minor releases) I thought it was safe to assume that the last Unity 4 version would be 4.6... I was wrong.

    So I now have to fix all of my assets :rolleyes: And I expect a lot of other assets and editor extensions to break with 4.7 as well.

    I'll push a patch asap.
     
  8. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    Yeah, they even explained why they used 4.7 instead of the planned 4.6.10. It's so stupid one can't write #if UNITY_VERSION < 5 or so...

    Oh, and thanks for that patch!
     
    Last edited: Dec 20, 2015
  9. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,297
    If it's any consolation, pretty much all assets "broke" because of the new platform define :)
     
  10. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The patch is up !
     
    ratking and AcidArrow like this.
  11. ratking

    ratking

    Joined:
    Feb 24, 2010
    Posts:
    215
    Thanks, that fixed the problems!
     
  12. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    are you able to exclude layers from this?
     
  13. 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.
     
  14. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    Is there anything I can do in my shaders to exclude them from the AO without causing any visual errors? Like for cloth?
     
  15. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Unless you can disable depth testing on them (so that they're not rendered in the depth buffer, like transparent objects), no. What kind of shader are you trying to exclude ?
     
  16. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    It's a cloth shader, but I can see harsh AO on the polygons as it's blowing in the wind
     
  17. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Which cloth shader ? I'm guessing it's a 2-sided shader ?
     
  18. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    It's a cloth shader I've written, it's two sided yes. It happens on both sides, but it's probably because the polygons are so large compared to your average model.
     
  19. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Ok, so using 2-sided shaders is not a good idea. Simply put, one side will work fine and the other will be borked because in 3D, normals can only be set on one side of a triangle. There are a few ways around this issue but they aren't practical. I remember talking about 2-sided materials on this topic, 3rd or 4th page I think.

    Now, the fact that polygons are very large shouldn't affect the way AO is applied in theory (it's pixel based, not geometry based). What's your rendering path ? Forward or Deferred ? Unity 4 or 5 ? Any chance you could post a screenshot ?
     
  20. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    The shader is working perfectly aside from the AO, this is my first issue with it. I've heard the geometry doubling method tons of times, it's not worth it with simulated cloth.

    We are using deferred, 5.3

     
    Last edited: Dec 22, 2015
  21. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hmm any chance you could post your shader (PM me if you don't want to make it public) so I can test it locally and see what's going on ?
     
  22. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    441
    I hear this works with Android, but its slow from what I read from a review..I was wondering if this is an issue...or just a set up issue from the user.. Has anyone else used this with mobile only.. Thanks for any input..
     
  23. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,297
    Running any kind of SSAO effect on mobile is a waste of resources.
     
    Chman likes this.
  24. Recon03

    Recon03

    Joined:
    Aug 5, 2013
    Posts:
    441

    I seen your post and thought what is he talking about...

    Wrong asset.. I was looking at them both at the same time

    https://www.assetstore.unity3d.com/en/#!/content/44845

    This is the one I was looking into ... my question still stands for that asset, I can post over there if needed.
    PS: But I have used Post processing effects with mobile with very little hit. You just need to use them properly, and use make sure your games is optimized properly.. So its not always a waste, most of the time I would agree.. I use very few..When I DO.. Certain shaders for water, caves etc, are in the same boat.. But I still use with very little hit.,.
     
    Last edited: Dec 28, 2015
  25. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Colorful FX runs fine on mobile devices, that is on Android and iOS, not sure about Blackberry and Windows Mobile. It's used in production and I had reports from mobile devs that it runs great as long as you don't go crazy with it (i.e. don't stack 50 effects at once on your camera). A few of the more advanced effects might be too expensive for older mobile hardware but overall it's good to go for production use !
     
  26. alphakanal

    alphakanal

    Joined:
    Jan 21, 2013
    Posts:
    35
    Hi,

    I have some questions / problem with using SSAO.

    The attached image shows an example cube. The cube is made in 3ds max ( 10m*10m*10m ) and a shell modifier on top ( 0.3m inside shell ). So it's like a simple room with walls. Export as FBX, import with scalefactor 1 - no mesh compression.

    I got a camera rotating around that cube and this produces flickering edges when using the SSAO in unity 5 ( the dark areas on the cube face ). The dark areas are there even when the camera is not moving. It's sure coming from the inner faces - but i can't ged rid of it..

    The flicker areas disappear when put the SSAO Distance up to 10 - but then i don't have AO at all...Reducing the Radius doesn't work...Bias also... i'm a little bit lost. Any ideas?
     

    Attached Files:

  27. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,955
    Make the camera clipping planes fit the scene tighter (reduce far- and increase near clipping). Does that help?
     
  28. alphakanal

    alphakanal

    Joined:
    Jan 21, 2013
    Posts:
    35
    YES!!! Thank you very much - reducing the near clipping plane was the right thing to do :)
     
    Martin_H likes this.
  29. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    Hi, I bought SESSAO but it doesn't work for my game, running around in forests all the trees have a white glow trailing them which is really uneasy on the eye, and once you get an aircraft and start flying around, things just get even worse.
    I can already see that the OP answers here on the forum which is already a huge plus compared to SESSAO, but I need to know if speed trees are a problem for this shader as they were for the other one? =)
     
  30. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,955
    You might need to give more specifics for @Chman to be able to give an answer. (I think) all SSAO effects work with the depth buffer and alpha blended materials don't write to the depth buffer so there can be artifacts wherever you use alpha blended materials. Maybe also cutout materials with MSAA? Which shader do you use for the foliage and which rendering path? Can you provide a screenshot with and without SESSAO? Does SESSAO have any temporal component? If so it might be as easy as turning that off. Does the free SSAO that is in the unity Standard assets give you the same problems as SESSAO?
     
  31. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Thanks @Martin_H ;) More details would help a lot (screenshot with SESSAO and with the default SSAO effect ? Deferred/forward rendering path ? What's the tree shader ?). But I'm pretty sure that if it doesn't work with SESSAO it won't work correctly with SSAO Pro either. It it does work with the default SSAO then it might work with SSAO Pro.
     
    Martin_H likes this.
  32. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    I can't answer much of that as I don't know, but as you can see from this screenshot (the settings have been exaggerated as it's far more pronounce when animated and not as much when it's just a single image), the effect happens from the mesh trees on terrain background. So there shouldn't be any alphablending going on, nor cutout effects or anything like that.
    The rendering path is Deferred.

    I don't know what a temporal component is, nor do I know if SESSAO has such a thing, however it's not a name I've come across in working with SESSAO.

    I haven't tried it with the standard SSAO shader, but I can test it tomorrow.
     

    Attached Files:

  33. Mr-Logan

    Mr-Logan

    Joined:
    Apr 13, 2006
    Posts:
    455
    The image is in the post above ^

    The rendering path Deferred
    I can check the tree shader tomorrow, however these are standard asset tree's with the default shader the standard assets use, I don't know off the top of my head what shader it is though =)

    I'll have to check out the standard SSAO asset when I get to my computer tomorrow then. =)
     
  34. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    I'm receiving the following error when building with Unity 5.3.2p1:

     
  35. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Are you trying to run SSAO Pro on iOS ? I would recommend against it as it will be very slow and I don't officially support it. SSAO on mobile is generally a big no-no. But you can fix the error by opening the /SSAO Pro/Resources/SSAOPro.cginc file, going to line 296 and removing the const keyword (first word in the line). It should compile fine then, but once again I can't guarantee that it will work correctly on iOS.
     
  36. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Target platform is Mac OSX, Architecture Universal. Auto Graphics API for Mac enabled. Using SSAO Pro 1.6.
     
  37. chiapet1021

    chiapet1021

    Joined:
    Jun 5, 2013
    Posts:
    604
    Whoa @Chman, congrats on joining Unity! :D
     
    hopeful and Chman like this.
  38. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Interesting. Are you running 5.4b3 ? Metal is still marked as "Experimental" on Mac OS X but you can always see if it works. For now, the best thing to do would be to stick to OpenGL Core (which should be the default). Untick "Auto Graphics API for Mac" and remove "Metal (Experimental)" from the list. "OpenGLCore" should be on top.
     
  39. silentneedle

    silentneedle

    Joined:
    Mar 14, 2013
    Posts:
    280
    Nope, I'm on 5.3.2p1. So that error results in running on Metal? That's strange, because on the Unity title it shows OpenGL 4.1.
     
  40. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I just checked and yes, "Metal (Experimental)" was available in 5.3. The way "Auto Graphics API for X" works is that it will build for all the specified API. Then, at runtime, it will try the first one from the list. If it fails, it will try the next one. And so on. It's a good way to have API fallbacks for computers that don't support the main API you're using (for instance on Windows you would have DirectX 12, then Directx 11, then Directx 9 etc). In the case of Mac OS X, Metal is part of that list but is put last (so it will probably never be used as all mac do support OpenGL as far as I know). And because it's in the list, it will be part of the build process... :)
     
    Last edited: Jan 29, 2016
    silentneedle likes this.
  41. oceanq

    oceanq

    Joined:
    Apr 10, 2015
    Posts:
    22
    Is anybody else getting streaking along the right side of their image in Unity 5.3.2?


    It looks like the SSAO is alright, but the underlying image stretches.
    Also, it works with the Deferred rendering path, just not with the Forward rendering path:
    Here it is in Deferred:



    More info: It looks like the streaking goes away if you disable shadows (in the forward renderer). So it seems like it has something to do with shadows....

    Thanks,
    Ocean
     
    Last edited: Feb 5, 2016
  42. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's a weird one. Are you running windows or mac ? What's the active graphics API (directx, opengl 2, opengl core...) ? Does it happens in a build too or only in the editor game view ? Is there any other image effect applied to the camera ?
     
  43. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,147
    Would like to know if you could add an option to the settings that allows to invert the AO to achieve a hdr-colored "glowing" effect similar to this:



    What I do not want is to invert the whole renderoutput like an invert-posteffect.
     
    Last edited: Jul 26, 2017
  44. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    3,955
    That sounds like something that wouldn't be too hard to do yourself. Have you tried playing around a bit with the (shader)code? It can be a lot of fun to customize such assets and you'll learn a bit along the way too.
     
  45. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,147
    Right, but I don´t know about writing shadercode and unfortunately don´t have the time to dive into it....
     
  46. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Inverting the AO is pretty easy but I don't know if it'll give you the result you want. Look for the SSAOPro.cginc file. At line 150 you should see the following :
    Code (CSharp):
    1. return ao;
    Change it to :
    Code (CSharp):
    1. return 1.0 - ao;
    Alternatively, you can instead go to lines 191 and 195 and replace all occurrences of ao and aofinal by 1.0 - ao and 1.0 - aofinal for a different, deeper result.
     
  47. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,182
    Perhaps even Lerp it with a parameter, shouldn't cost much more and be nicely tweakable in game.
     
  48. oceanq

    oceanq

    Joined:
    Apr 10, 2015
    Posts:
    22
    Looks like it's a known bug in 5.3, that's already been fixed in 5.4
    Talking about it here:
    http://forum.unity3d.com/threads/smeared-objects-above-horizon-line.381078/#post-2497210
     
    Chman likes this.
  49. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,411
    The SSAO effect is rendered upside down in 5.4b4. DX11, SSAO Pro 1.6. Is it a known issue?

    Capture.JPG
     
    Mr-Logan likes this.
  50. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yep, it's a bug with the GameView in Unity 5.4beta (it should work ok in builds though).
     
unityunity