Search Unity

  1. 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

SSAO Pro - High Quality Screen-Space Ambient Occlusion

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

  1. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    314
    Hey there -- I'm getting an unexpected "Unsupported shader (SSAO)." message from line 161 of the SSAOPro file. This is in the default demo scene that comes with SSAO Pro, as well as in my own scenes.

    I'm running DX9 on purpose (compatibility with the most people), on windows 10, unity 64bit editor, 5.3.2f1, deferred rendering, GTX 980M card. I really have a hard time believing my card doesn't support this, so I'm presuming that either this is a bug or something strange in my project settings is interfering with even the demo scene.

    I'm able to use Amplify Color, Scion, FXAA, and PRISM all with no trouble with these project settings, so I'm really not quite sure what this would be. (I'm not running all those things at the same time, of course!)
     
  2. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hey !

    Could you select the shader in the Project panel and look for errors in the inspector ? Most likely the shader failed to compile for some reason (my best guess would be that it failed to find the shader include file due to some asset refresh issue... In this case simply select the shader and SSAOPro.cginc in the Project panel, right click and Reimport).
     
    x4000 likes this.
  3. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    314
    That is... super duper odd. Basically here is what I think happened:
    1. I import this from the asset store.
    2. It does its thing, and then I move it to a CameraEffects subfolder for the sake of organization.
    3. It tries to compile, but it was getting "Could not find SSAOPro.cginc" errors on import (thanks for the tip on where to find that).

    Here's where it gets really strange. Not reading your post carefully (my bad), I just casually tried to hit recompile on the shader again. Didn't work. So I figure that it must be a path thing (grumble grumble). So I copy the SSAO Pro folder back to the root folder. Try to compile the shader again in that same fashion. Does not work.

    So I read your instructions more carefully, then right-click and hit reimport. Boom, works like a charm. I figure that I may as well try moving it back into the CameraEffects subfolder and see if it wigs out again. It moves just fine. Suspicious, I reimport it again, this time at the new location that presumably was a problem before. No issues are encountered.

    That leaves me... baffled. Your solution is simple and worked immediately, but I'm not really clear what I did that caused the issue in the first place. Clearly the path doesn't matter (thank you!), so I guess unity just had "one of those moments." I know it's nothing to do with your code at all, but I just find it to be a curiosity. I was kind of hoping I'd have a clear "do this and it breaks until your right-click and hit reimport" case that you could add to your faq. I suppose the case is just "if it wigs out for whatever reason." ;)

    Anyway, thanks again -- I'm a happy guy now.
     
    Chman likes this.
  4. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,132
    What I have gathered from this and other circumstances is ... sometimes you have to re-import something to get it to work right, especially if it is a shader. :)
     
    x4000 likes this.
  5. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    314
    Rather like steam with the "please verify your file cache." It's once in a blue moon that actually matters, but man after 6 years of players occasionally bringing me a strange issue and that being like 1 in 100 the case, it still gets me.
     
  6. deab

    deab

    Joined:
    Aug 11, 2013
    Posts:
    84
  7. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Not sure what's going on there. I'll ask a few people tomorrow at work.
     
  8. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    372
    Hello, we are using SSAO Pro on our project and we are happy with it's quality.
    We have set up graphics setting script. And in high graphics SSAO pro component is enabled. In other settings it's disabled. Hovewer after Enabling SSAO Pro and disabling it, Draw call affect sits there and game runs slower. I don't want to restart scene after setting graphics. Is there a better way to disable SSAO Pro? After enabling and then disabling component, camera component gets this notification: "Info: renders Depth&DepthNormals textures"
     
  9. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hello,

    You can add the following code to the SSAOPro class (note that this will only matter if you use the Forward rendering path, as I suspect you do) :

    Code (CSharp):
    1. void OnDisable()
    2. {
    3.     m_Camera.depthTextureMode &= DepthTextureMode.Depth;
    4.     m_Camera.depthTextureMode &= DepthTextureMode.DepthNormals;
    5. }
    I didn't put this in the package for one reason : these buffers may be used somewhere else, so disabling these flags could potentially break other effects... But if SSAO Pro is the only one needing them in your scene, then you can safely inject the code above :)
     
  10. deab

    deab

    Joined:
    Aug 11, 2013
    Posts:
    84
    @Chman I'm using deferred rendering path.
     
  11. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,172
    I can´t read the whole thread, is there already a comparison to the new Unity-Cinematic-Beta AmbientOcclusion?

    At a first glance it was kind of convincing to me.....
     
  12. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Here comes SSAO Pro 2.0 (for Unity 5 only) ! A lot of small fixes, global code cleanup, much better blur quality. Enjoy !

    Changelog (2.0) :
    • Important: This release is only compatible with Unity 5+. The previous version (1.6.2) is still available for Unity 4 users.
    • Removed: Bilateral Blur filter. Its quality was quite bad and the "HQ Bilateral Blur" filter is barely slower.
    • Modified: Reworked the "HQ Bilateral Blur" filter to look much better. You'll have to tweak the "Threshold" value as its range has changed.
    • Fixed: "First-frame AO glitch" bug.
    • Misc: Reduce the number of shader keywords required.
    • Misc: Did a global beauty pass on the code, better fail checks, better resource cleanup, and more future-proof code.
     
  13. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    So the bug still present for the Unity 4 users :confused:
    You copy the bad practices of UT. Welcome in board.
     
  14. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Huh... That was a quick fix right before I pushed the package to the store. I'll backport it to the Unity 4 version (might take a few days as I'm currently away).
     
  15. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,646
    Thanks and sorry.
     
  16. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I found some time to backport the fix to SSAO Pro 1.6.x, sorry about that :) If you're a Unity 4 user, simply update / redownload the package from the store !

    Changelog (1.6.3 for Unity 4.5+) :
    • Fixed: "First-frame AO glitch" bug (backported for Unity 4.5+ from SSAO Pro 2.0).
     
    elias_t and ZJP like this.
  17. Unreal-Vision

    Unreal-Vision

    Joined:
    May 6, 2013
    Posts:
    58
    Hi Chman,

    I have an issue with SSAO Pro and Unity 5.4b16.
    If SSAO Pro is active, I'm not able to see "Global Illumination" Pass (UV Chart, irradiance, etc...) in the Scene viewport. Everything is rendered black.
    If I disable SSAO Pro, everything works fine.

    Are you able to reproduce? :)
     
  18. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Do you have Image Effects enabled in the scene view ? It's a new feature of Unity 5.4 and I enabled it for SSAO Pro too. You can disable it in the Effect toolbar or you can exclude SSAO Pro from it by opening SSAOPro.cs and commenting line 13 :

    Code (CSharp):
    1. #if UNITY_5_4_OR_NEWER
    2. [ImageEffectAllowedInSceneView] // -> comment this line
    3. #endif
     
  19. Unreal-Vision

    Unreal-Vision

    Joined:
    May 6, 2013
    Posts:
    58
    Hi Chman,

    Disabling Image Effect in Scene View, now I'm able to check GI pass :)

    Thanks for trick! You think could be fixed in next release? Imaged Effect preview is very useful.

    Thanks,
     
  20. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I'll see what I can do, but I'm afraid it might be an issue with how the image effect preview works in the gameview in 5.4. I'm seeing the same kind of issue with SSR and effects that need to be injected in the middle of the render loop instead of being applied at the very end.

    I'll try and come up with a solution, if I can.
     
  21. jwilliamsen

    jwilliamsen

    Joined:
    Aug 8, 2010
    Posts:
    56
    Hi Chman,

    Any progress in regards to the ability to exclude objects on a particular layer? I love the effect of the SSAO, but it makes my characters look like they need a bath - and since I'm developing VR, I don't think adding cameras is a good idea... ;)

    Thanks,

    Joe
     
  22. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Still no good solution as of now. SSAO Pro makes use of the Depth & Normals buffers generated by Unity and there's no easy way to properly exclude objects from them to begin with. So unless you can afford to render these objects in the transparent pass it's not possible right now.
     
  23. Sebioff

    Sebioff

    Joined:
    Dec 22, 2013
    Posts:
    186
    Ran into the "problem" with depth/depthNormals still being enabled when disabling SSAOPro as well :)
    Could setting the depthTextureMode in OnPreRender and resetting it in OnPostRender be a way to handle it without interfering with other effects?

    Code (CSharp):
    1.     void OnPreRender()
    2.     {
    3.         depthTextureMode = m_Camera.depthTextureMode;
    4.  
    5.         // Depth & normal maps
    6.         m_Camera.depthTextureMode |= DepthTextureMode.Depth;
    7.         m_Camera.depthTextureMode |= DepthTextureMode.DepthNormals;
    8.     }
    9.  
    10.     void OnPostRender()
    11.     {
    12.         m_Camera.depthTextureMode = depthTextureMode;
    13.     }
     
  24. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Indeed. OnPostRender to reset the depthTextureMode should be fine, although I'd put it at the end of OnRenderImage just to be extra sure (as it happens after OnPostRender).
     
  25. Toba

    Toba

    Joined:
    Oct 19, 2012
    Posts:
    3
    Hi there, I just bouught the package and I have a problem. I use multyple cameras to draw different things in each layers. If I add the SSAO to the one above all (the one with higher Depth), which I use only for effects (Culling Mask: Nothing) it does nothing. And if I add the script to the camera that renders most of the world, it stops showing the particle systems (yeah weird) and also does nothing with the script.

    The only way I made it work is apllying it to the one above all and turning on all the Renders (Culling Mask: Everything), but that is not what I'm looking for.

    Am I missing something?

    Thanks,

    By the way, the support email at the Asset Store goes to a blank page.
     
  26. gamearti5t

    gamearti5t

    Joined:
    May 25, 2016
    Posts:
    19
    It's a little off topic, but could you share with me how you set up the single camera setup with UFPS? I am struggeling to get the SSAO Pro to work with multiple cams in UFPS. Thanks so much!

    EDIT: Nevermind, found it already. UFPS does have a retraction tutorial, which explains it: https://docs.google.com/document/d/...3KzMfsPUGBI/pub?embedded=true#id.ufpg3gltyrcq
    SSAO Pro works like a charm now!
     
    Last edited: Jun 1, 2016
  27. gamearti5t

    gamearti5t

    Joined:
    May 25, 2016
    Posts:
    19
    Quick question: Is there any way to prevent transparent grass planes (which hold a texture with an alpha mask) from having the AO effect? Would love to use SSAO Pro but my grass starts to have those dark fillings now:

     
  28. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Sorry for the delay everyone, I've been away this week.
    No, that's unfortunately due to a bunch of limitations with how the multi-camera system works in Unity, the way depth is handled, and whether you're in Forward or Deferred also changes the way it works. To be honest I'm not sure what's the best way to achieve what you're trying to do so I'm not exactly sure what to tell you to fix this behavior...
    Thanks for the report, but I just tried it and it seems to work fine ? Maybe there was a bug in the Asset Store backend and they fixed it since then.
    That's most likely due to a bad render queue setup in the shader or an issue with normals on the mesh itself. Is that a custom shader ?
     
  29. gamearti5t

    gamearti5t

    Joined:
    May 25, 2016
    Posts:
    19
    @Chman yes it is a custom grass shader based on shader forge. And idea of how to solve this?
     
    Last edited: Jun 12, 2016
  30. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I'm not familiar with Shader Forge, but I've seen people with similar issues and they were able to fix it somehow. Could you send me the generated shader so I can take a look ?

    Also, are you running in Forward or Deferred ?
     
  31. ElliottMallard

    ElliottMallard

    Joined:
    Jul 2, 2015
    Posts:
    18
    Hi,

    Does anybody know why SSAO or any other kind of AO image effect causes horrible white edges (almost like REALLY bad aliasing?) It's particularly noticeable in this case as it's black window frames on black glass.

    SSAOWO.jpg SSAOWith.jpg
     
  32. Derek_Knochel

    Derek_Knochel

    Joined:
    Jun 1, 2016
    Posts:
    8
    Has anyone tried this asset in VR with single pass stereo? Unity's own ssao solutions don't work reliably.
     
  33. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hi, looking at your first screen, I'm guessing you have MSAA enabled. This is unfortunately known to cause artifacts with current SSAO solutions for multiple reasons (SSAO downscaling, AO samples not being part of the multisampling pass etc). One solution in this case is to stop using MSAA and use a full-screen antialiasing solution instead (like FXAA, SMAA, etc).
    SSAO Pro doesn't support single pass stereo correctly yet as far as I know. I'll look into it.
     
    Derek_Knochel likes this.
  34. gamearti5t

    gamearti5t

    Joined:
    May 25, 2016
    Posts:
    19
    @Chman,
    Sorry for my delay. I did some more testing and the problem with the shadow affecting the whole geometry/plane for grass/trees also happens with the SpeedTree models provided in Unity when using forward rendering (see attached images). However when I switch to deferred or legacy deferred the shadows on SpeedTree are gone but are still visible on the grass as described in my former post.
    Do you have an email, so I can send you the shader which is used for the grass?
    Thanks so much!

    PS: Since Speedtree has some issues with highlights in deferred rendering I am aiming to use forward rendering.


    SSAO-Prob-1.jpg SSAO-Prob-2.jpg
     
  35. Twoonebe

    Twoonebe

    Joined:
    Mar 30, 2013
    Posts:
    174
    Hi can you help me please, i can not turn SSAO on and got this warning message in unity

    Unsupported shader (SSAO).
    UnityEngine.Debug:LogWarning(Object)
    SSAOPro:OnEnable() (at Assets/_Complete Tools/SSAO Pro/Scripts/SSAOPro.cs:148)
    UnityEditor.DockArea:OnGUI()
     
  36. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yep, it's on my publisher page ;) There are so many issues with speed tree shaders right now...

    Most likely the shader failed to compile because it couldn't find the CG include file which is in the same folder. Look for the /SSAO Pro/Resources/ folder in the Project panel, right click on it and choose Reimport. That should fix it. It happens sometimes when Unity fails to import a package properly for some reason.
     
  37. sjm-tech

    sjm-tech

    Joined:
    Sep 23, 2010
    Posts:
    708
    In this thread there are some custom fixes to use speedtree on deferred rendering (and ssao pro too;)) without much notable issues.
    Hope this helps.
     
    Last edited: Jun 30, 2016
    TeagansDad likes this.
  38. gwnsf

    gwnsf

    Joined:
    Nov 13, 2015
    Posts:
    1
    I'm getting a lot of artifacts and wavy lines if I do not set my near clip plane to 0.3 or higher, is this a bug?
     
  39. NonnoNonno

    NonnoNonno

    Joined:
    Sep 19, 2015
    Posts:
    1
    Hi. I bought it yesterday, but didn't use it yet, because deactivation of SSAO component button(in main camera) & console warning message.
    "Unsupported shader (SSAO). UnityEngine.Debug:LogWarning(Object)"
    What should I do? Please any idea what it could be..
     

    Attached Files:

  40. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hi, sorry for the delay I've away for the whole week.

    Most likely the shader failed to compile because it couldn't find the CG include file which is in the same folder. Look for the /SSAO Pro/Resources/ folder in the Project panel, right click on it and choose Reimport. That should fix it. It happens sometimes when Unity fails to import a package properly for some reason.
     
  41. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    695
    I have this issue when using SSAO PRO:
    dsadasda.png

    For various reasons, I need to create a shader with exclude_path:deferred. But when doing this, and also using tessellation, these artifacts are displayed.

    Code (CSharp):
    1. Shader "Custom/SSAOTEST" {
    2.     Properties {
    3.         _Color ("Color", Color) = (1,1,1,1)
    4.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    5.         _Glossiness ("Smoothness", Range(0,1)) = 0.5
    6.         _Metallic ("Metallic", Range(0,1)) = 0.0
    7.         _Smoothness ("Tess smoothness", Range(0,1)) = 0.0
    8.     }
    9.     SubShader {
    10.         Tags { "RenderType"="Opaque" "Queue"="Geometry" }
    11.         LOD 200
    12.        
    13.         CGPROGRAM
    14.         // Physically based Standard lighting model, and enable shadows on all light types
    15.         #pragma surface surf Standard fullforwardshadows addshadow tessellate:tessEdge tessphong:_Smoothness exclude_path:deferred vertex:vert
    16.  
    17.         // Use shader model 3.0 target, to get nicer looking lighting
    18.         #pragma target 3.0
    19.        
    20.         struct appdata
    21.         {
    22.             float4 vertex : POSITION;
    23.             float4 tangent : TANGENT;
    24.             float3 normal : NORMAL;
    25.             float4 color : COLOR;
    26.             float2 texcoord : TEXCOORD0;
    27.             float2 texcoord1 : TEXCOORD1;
    28.             float2 texcoord2 : TEXCOORD2;
    29.             float2 texcoord3 : TEXCOORD3;
    30.         };
    31.  
    32.         sampler2D _MainTex;
    33.  
    34.         struct Input {
    35.             float2 uv_MainTex;
    36.         };
    37.  
    38.         half _Glossiness;
    39.         half _Smoothness;
    40.         half _Metallic;
    41.         fixed4 _Color;
    42.        
    43.         void vert(inout appdata vertex)
    44.         {
    45.            
    46.         }
    47.        
    48.         float4 tessEdge (appdata v0, appdata v1, appdata v2)
    49.         {
    50.             return 4;
    51.         }
    52.  
    53.         void surf (Input IN, inout SurfaceOutputStandard o) {
    54.             // Albedo comes from a texture tinted by color
    55.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
    56.             o.Albedo = c.rgb;
    57.             // clip(-1);
    58.             // Metallic and smoothness come from slider variables
    59.             o.Metallic = _Metallic;
    60.             o.Smoothness = _Glossiness;
    61.             o.Alpha = c.a;
    62.         }
    63.         ENDCG
    64.     }
    65.     FallBack "Diffuse"
    66. }
    67.  
    This does not happen in forward rendering, only deferred.

    Is there a way to fix this?
     
  42. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I can reproduce this issue, but unfortunately I don't have any solution for you as it's not an issue with SSAO Pro. Here's a debug screenshot of the normal buffer generated by Unity (as fed to SSAO Pro) :



    As you can see, the normals are all broken for some reason. I'm curious though, why do you need to exclude deferred when you're using the deferred rendering path ?
     
    SunnySunshine likes this.
  43. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    695
    Yeah, I thought as much. Unity's own SSAO effect suffers from the same issue. For now I'm resorting to rendering the object 2 times with different materials. That seems to fix it.

    The reason I need to exclude the deferred pass is because I'm basically hacking the output of a surface shader to alter the way it behaves, and this does not work in deferred, only forward. So that's why I'm excluding that path to basically force forward render for this shader.
     
  44. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    695
    I get this issue when using SSAO Pro with custom lighting:

    with.png

    Without SSAO Pro:

    without.png

    Code (CSharp):
    1. Shader "Custom/ClipTest" {
    2.    
    3.     Properties {
    4.         _Color ("Color", Color) = (1,1,1,1)
    5.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
    6.         _Cutoff("Cutoff", Range(0,1)) = 0.0
    7.     }
    8.     SubShader {
    9.         Tags { "RenderType"="AlphaTest" "Queue"="AlphaTest" }
    10.         LOD 200
    11.        
    12.         CGPROGRAM
    13.         #pragma surface surf SimpleLambert addshadow alphatest:_Cutoff
    14.  
    15.         half4 LightingSimpleLambert (SurfaceOutput s, half3 lightDir, half atten) {
    16.             half NdotL = dot (s.Normal, lightDir);
    17.             half4 c;
    18.             c.rgb = s.Albedo * _LightColor0.rgb * (NdotL * atten);
    19.             c.a = s.Alpha;
    20.             return c;
    21.         }
    22.        
    23.         float4 _Color;
    24.  
    25.         struct Input {
    26.             float2 uv_MainTex;
    27.         };
    28.        
    29.         sampler2D _MainTex;
    30.        
    31.         void surf (Input IN, inout SurfaceOutput o) {
    32.             fixed4 c = tex2D (_MainTex, IN.uv_MainTex);
    33.             o.Albedo = _Color;
    34.             o.Alpha = c.a;
    35.         }
    36.         ENDCG
    37.     }
    38.     FallBack "Diffuse"
    39. }
    Is there a way to fix this?
     
  45. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The correct RenderType is TransparentCutout, so changing the tags to :
    Code (CSharp):
    1. Tags {"Queue"="AlphaTest" "RenderType"="TransparentCutout"}
    Should fix this :)
     
    SunnySunshine likes this.
  46. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    695
    Amazing, such a simple mistake. Thanks a bunch!
     
  47. SunnySunshine

    SunnySunshine

    Joined:
    May 18, 2009
    Posts:
    695
    I've noticed that performance drops significantly when objects are close to the camera with SSAO on. What is the reason for this?
     
  48. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    This reply explains it :)
     
    SunnySunshine likes this.
  49. Games-Foundry

    Games-Foundry

    Joined:
    May 19, 2011
    Posts:
    632
    Bug Report.

    In Win 10 x64 standalone (both DX11 and 12, deferred), while testing Unity 5.4.0p4, with SSAO Pro 1.6.x enabled we're getting random flashing lines and triangles. They don't occur when SSAO Pro is disabled. Sometimes they are tinted red. Running on an NVidia GTX 780Ti.

     
    Last edited: Sep 1, 2016
  50. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hmm that's weird. Did it happen with 5.4.0p3 ? Or did you come from a previous version (pre-5.4) ?
     
unityunity