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

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,766
    In my scenes I am using a combination of baked lighting and realtime lights (no pre-computed realtime GI). Is the SSAO pro designed to work with both baked lighting and realtime lighting (no realtime GI)? Currently I am not baking any AO. My understanding is that SSAO provide could provides better AO than what can be baked in Unity.
    Could you explain the visual differences between SSAO pro vs. unity's baked AO? (Or are theese two completely different things?) I am interested in the product.
    Thanks.
     
    Last edited: Feb 9, 2016
  2. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    very useful asset.

    Can work in mobile device?
     
  3. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    It can, potentially. But it's an heavy effect targeted for desktop & consoles, so even if it works it will be too slow to be usable anyway.
    So, SSAO is a way to fake realtime ambient occlusion. Because it works in screen-space and has to be fast it will never be as good as properly baked, high resolution AO. But it's realtime, so any opaque, dynamic object will cast and receive ambient occlusion, whereas baked AO would be completely static. It's a matter of needs and preferences. If you're only working with static, well-lighted scenes, bake your AO. If you have a dynamic scene and need that extra little thing to make it pop, then SSAO is for you. And of course you can also mix them although it has to be carefully tuned to look good. And yes, SSAO Pro will work with baked and/or dynamic lighting. It's a post-processing effect so it will work with whatever the camera throws at it.

    Hope this helped ! Don't forget to check out the online documentation to better understand what it's about.
     
    ArachnidAnimal and Martin_H like this.
  4. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,766
    Ok, thanks for the explanation. I have not had very good experiences so far with baked AO in unity, I'm trying to avoid it. And the key words you mentioned are : "high resolution baked AO". I want to avoid high resolution baked GI since I am also using realtime lights on top of the baked lights (mixed lights). It soulds like SSAO camera effect is better for my situation.
     
  5. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,766
    Hello,

    Where in the camera effects do you recommend placing the SSAO pro? I believed it should be the very first camera effect. Is this correct? Thanks


    Thank you
     
    Last edited: Feb 14, 2016
  6. alexandresk

    alexandresk

    Joined:
    Jul 11, 2013
    Posts:
    51
    Hi there, I was trying to understand how the performance drop occur.

    I see in the Profiler, in the GPU Usage I get around 4,5ms ( from 2.5 to 5.5ms ) ALL the time, whatever I have 30k triangles in scene or 3M. Is this normal?

    EDIT: After reading the Documentation I see it is not dependent on the geometry but only in the settings. Great asset by the way.
     
    Last edited: Feb 15, 2016
  7. alexandresk

    alexandresk

    Joined:
    Jul 11, 2013
    Posts:
    51
    Just attached it to the camera, the cameras without it will stay unchanged.
     
  8. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
    does it work for WebGL?
     
  9. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Anywhere you want, really. It will happen after all opaque objects have been rendered (before transparent objects).
    So as you read in the documentation it does not depend on the geometry complexity. It will depend on the screen resolution and how close the camera is to an ambient occluded area. I'm curious about your numbers, what's your GPU?
    Yes. I just tried with Unity 5.3.2 and it seems to work fine.
     
  10. DxStd_IgnatPribylov

    DxStd_IgnatPribylov

    Joined:
    Sep 24, 2015
    Posts:
    30
  11. alexandresk

    alexandresk

    Joined:
    Jul 11, 2013
    Posts:
    51
    Hi, well, I have a gtx 750 ti. But in the test I was using very hard settings, full HD, and mod the Radius to 5.

    Actually I am testing 2 scenes with same settings and I get different results, in one about 4.5ms and on the other 2.5ms with same models, quality, everything. Did not find why.

    I will see more on that, close to the end of the game, about July, game launches September.

    I also see a call in the profiler call: UpdateDepthNormalTexture. Is from the SSAO right?
     
    Last edited: Feb 20, 2016
  12. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Are you using any orthographic camera projections by chance?
     
  13. alexandresk

    alexandresk

    Joined:
    Jul 11, 2013
    Posts:
    51
    No, but I will work on it later. Thanks
     
  14. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Are you profiling in the editor or in a build ? Make sure the cameras in both scene use the same render path (see next quote/reply).
    It means you're probably using the Forward rendering path so Unity has to make an additional pass to generate the depth & normal textures that SSAO Pro needs. If you switch to deferred rendering this call should go away.
     
  15. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I just noticed a vast difference in SSAO pro performance that is depending on the distance from camera to geometry. If I get very close with the camera SSAO pro takes ~7-8ms per frame and if I go further away it is below 1ms. I increased the max distance to 100k to make sure it isn't caused by that. Can you please explain why this is reacting this way? I thought a screenspace effect shouldn't be affected by the screen content in such a big way.

    When I make the FOV narrow, disable everything except cam with ssao pro and scion, light and a single textured plane that fills the screen and I move the cam further towards the plane, then there is a distance where I get that bad performance, and distances further away AND closer to the plane have significantly better performance.
     
  16. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    With low radiuses, SSAO will only have to sample pixels that are very close (in clip space) to the original one, which is good for performances as they can be cached efficiently. With high radiuses, the generated samples will be further away from the original pixel and won't benefit from caching (think of it as a random memory access pattern, which doesn't perform very well on GPUs), thus slowing down the effect.

    Objects near the front plane will use larger radiuses than those far away (because perspective). So computing the AO pass for an object very close to the camera will be slower than for an object miles away that only occupies a few pixels on screen. It's all about cache efficiency.

    Hope this makes sense !
     
    hopeful likes this.
  17. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Thanks a lot for the explanation. It makes sense to me up until the fps go up again when I move the camera even closer. Is there a "min distance" between camera and object, where the samples are discarded more efficiently because the object is "too close"? Would it be a useful optimization to clamp the perspective influence on radius scaling to a different max value? The performance impact seems to be quite dramatic and I wonder if it would be a good tradeoff to cap this. But maybe one of the sliders already does this and I just didn't know yet?
     
  18. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    The min distance would be the one from your camera settings (near plane). When you say that performances go up when the object is too close, do you still see the AO ? Or does it get lighter ?
    Radius is already treated as a "max radius" value actually, in world space (and there's a hidden min radius as well to avoid getting too many noisy artifacts in the distance) :) But having a max radius in clip space would look weird (same as having a fixed radius no matter what the distance to the sample is). If that were to be implemented, you would see the AO grow and shrink as the camera moves (kind of like a vertigo effect). I let you imagine how that'd look...

    It's always been a problem with SSAO algorithms and the best way to alleviate this issue if you need big radiuses or very upclose AO is to downsample the AO pass.
     
  19. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    Ok, now it's starting to make sense to me. Thanks a lot for explaining! I was trying to reproduce the behaviour in a different scene today but I didn't manage to do that. I also didn't save the one from yesterday unfortunately. If I ever get to isolate what special constellation of circumstances gets the heavy performance drop I'll post here, so that potentially others can avoid that situation. But other than that I'll just keep in mind that the performance of SSAO effects isn't as independant of the screen content as I thought. Learned something new :).
     
  20. alexandresk

    alexandresk

    Joined:
    Jul 11, 2013
    Posts:
    51
    Thanks for answers, I actually have been able to reduce time to 1.5-2.0ms with good quality on 1960x1080. I didn't have turn off the noise so I was needing too much blur. Unfortunately my game is a cartoon/low poly style so.....

    Oh and the different times for the different scenes was because the distance, one with close ground, other without.

    Thanks for the feedback
     
  21. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    @Chman
    You work at Unity Technologies Now? :eek:



    :cool:
     
  22. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    Today I had this problem. If some will have something similar, for me it was caused by unstable version of vlight plugin. No the one that is available at the store, but the one was sent to me by the developer.

     
    Last edited: Feb 23, 2016
  23. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Does it work in deferred ? My first guess would be that your tree shader isn't writing correct information to the depth and/or normal buffers in Unity... Which would also explain why the AO looks wrong on the tree itself.
     
  24. isykaleo

    isykaleo

    Joined:
    Jun 27, 2015
    Posts:
    4
    Hi There,

    We have been using your plugin in our mobile application, and really creates amazingly AO effects!
    However, after recently upgrading to iOS version 9.2.1. A layer of black dot will appear when the SSAO effect is switched on (it also appears on the offical demo).
    IMG_7886.jpg QQ图片201602241753482.jpg




    Is there anyway we can fix this?
    Thanks and regards,

    Isaac
     
  25. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hi,

    Someone else got the same issue on latest iOS versions but I haven't found the source of the problem yet. So unfortunately no, there's currently no way to fix it but I'm looking into it.

    As a side note, please be aware that SSAO Pro isn't officially supported on mobile devices (it's not meant to run on these platforms at all to begin with)... I'll try to fix it eventually but I can't promise anything.
     
  26. isykaleo

    isykaleo

    Joined:
    Jun 27, 2015
    Posts:
    4
    Noted with thanks! I'll keep you posted if we find any solution on our side as well. :)
     
  27. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Maintenance update available !

    Changelog (1.6.2) :
    • Fixed: Compilation bug on PS4.
    • Fixed: Compilation bug on iOS/Metal, not that you should run it on mobile anyway...
    • Misc: Some minor improvements.
     
  28. ndntennisman

    ndntennisman

    Joined:
    Jan 19, 2015
    Posts:
    2
    I know I can't make specific objects be skipped by the ambient occlusion shader. But can I apply a material on it during run time so it is a different color?[/QUOTE]
     
  29. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    Hi Thomas,

    I would like to file a bugreport. In my project I'm using the Deferred->Linear pipeline (as required to use Alloy). However I'm noticing skybox bleeding when running through my scene. I'm afraid I have to report the SSAO package is turning out to be the source of the issue.
    This is my camera setup (UFPS - single camera!):
    SSAOPro01.png
    When I'm working through my scene I'm getting this kind of skybox artifacts:
    SSAOPro02.png
    While disabling the SSAO post effect (and restarting the game) everything is back to normal:
    SSAOPro03.png
    Anything I'm missing? My setup: Windows 10 Pro 64bit, Intel Core i7 3930K, Rampage IV Formula, NVidia Geforce GTX 660 Ti with Unity 5.3.3p1and SSAO Pro 1.6.2. (Same issue spotted on 1.6.0)

    Kind regards,

    Wim
     
  30. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    I assume the artifact is the pure black area visible in the sky ?

    Just curious : have you tried with the default SSAO effect (the one that comes with the standard effects package) ? If not, could you try it and see if you get the same artifact ? Also, is the artifact still visible when you toggle "Show AO" ?
     
  31. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    Indeed, the black area is indeed the artifact I'm talking about (moving across the sky).
    The default SSAO effect does display the same behavior. When showing the AO there is nothing special at that location (except a white area).
    SSAOPro04.png
    Did some further testing and switching the camera to forward rendering does get rid of the problem, though I'm bound to deferred for Alloy so no option.
     
  32. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    Well I can change the color as it seems :eek:
    SSAOPro05.png
    I changed the camera background to red and although the Clear Flag indicates Skybox the artifact is using the background color. So I did test it with the default skybox (thinking mine wasn't good) but same issue.
     
  33. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Hmm if the default SSAO exhibits the same behavior... Something's not right. And that AO-only view looks pretty much wrong. I wonder if Alloy is doing some manipulations to the depth and/or normal buffers...

    SSAO Pro is supposed to work fine in Deferred + Linear (actually that's how I setup all my projects). I don't have an Alloy license to test it right now but I'll try and contact the Alloy authors to see if they have any idea about what could be causing this issue.
     
    cygnusprojects and Martin_H like this.
  34. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    Thank you very much to follow this up, has been bugging me for a while.
     
  35. Deleted User

    Deleted User

    Guest

    @Chman
    We only manipulate the normal buffer alpha, and only when using our deferred skin system. In general, we output Unity-compatible values to the G-Buffer precisely because we want third party post-effect compatibility without extra work.

    I'm not sure what is going on here. :/
     
  36. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Yeah it's strange. I'll check it out in the coming days and see if I can find out why it's not working as expected.
     
  37. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    I'm having a strange issue ever since updating to Unity 5 with SSAO Pro.

    Below are two images. The top one is just a simple scene, a trophy in a box with one light and all Unity default materials using a forward rendering camera with no SSAO applied.

    The bottom image is what SSAO Pro is showing with the "Show AO" option selected. Essentially, it appears as though the scene is being lit from a directional light from the front. The more tipped away from the camera a surface is, the darker it gets. It exhibits this behavior in both my actual project, and in any small test scenes I create.

    My guess is that the Depth is being rendered out correctly, but the Normals are not? But I am not sure how to correct the problem, since it exhibits it with any of the default shaders, plus any of my custom ones. Any ideas?


     
    vonpixel likes this.
  38. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    Have you re-downloaded SSAO Pro from Unity 5 ? Because it's slightly different from the Unity 4 one and the asset store will only download the package for the version you're downloading from.
     
  39. astrospoon

    astrospoon

    Joined:
    Mar 23, 2009
    Posts:
    16
    I had re-downloaded for Unity 5, but it ended up being a similar cause. I had forgotten that I had slightly edited the Camera-DepthNormalTexture shader file and had the modified copy in my project from Unity 4. Removing those copies allowed Unity to grab the Unity 5 versions and everything is working correctly now. Just posting this in case some other unfortunate soul runs into this problem.
     
  40. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    @cygnusprojects
    I just messed around with Alloy + SSAO Pro, trying multiple setups (with/without Alloy Deferred Renderer Plus, Linear/Gamma, default and custom skyboxes, mixing Unity materials and Alloy materials, etc) and I'm not able to reproduce the bug you're seeing on two different computers. SSAO Pro seems to be working perfectly fine with Alloy.

    So to be honest I'm not sure what's going on here. Are you able to reproduce it in a new scene using a very basic setup ? If you could provide a repro-case that would be very helpful, even though I'm pretty sure it doesn't come from SSAO Pro as the default SSAO apparently does the same thing to your scene, and Alloy is probably not at fault either as it seems to work fine no matter what I throw at it.
     
    Deleted User and xenius like this.
  41. Brity

    Brity

    Joined:
    Feb 27, 2016
    Posts:
    116
    Try changing your model import settings. Try "generate normal" or import normal ect..
     
  42. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    I'll try to create a repo case and let you know.
     
    Chman likes this.
  43. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    766
    Hi @Chman,
    Good news! I cracked it! While making a slimmed down project for you, I noticed when I removed the existing Gaia components the issue went away. So did some boolean searching and found out that some spawned game objects (rocks) had a RTP Blend shader attached but not the controlling script. For testing I replaced the blending shader with the Alloy Core and the red spaces in my sky did disappear. For some reason that blending shader was treated as transparent I guess (screwing up the dept buffer?), switching to Alloy did reveal a lot of rocks in my scene I didn't even know they existed. Standing behind one of those looking at the sky triggered the artifact.
    Case closed! Thanks for the great support though.
     
    Deleted User, Martin_H and Chman like this.
  44. Deleted User

    Deleted User

    Guest

    @Chman @cygnusprojects
    Well that's a relief. Keep me posted if you have any future problems. Rest assured, we wish to maintain smooth compatibility with products such as SSAO Pro. ;)
     
    xenius and cygnusprojects like this.
  45. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
    Hi, Loving this asset, only one problem is with my torch using a particle with "Particles/Additive" shader.

    It almost not appears, when I put the "Soft particles Factor" setting to maximum it is better, but still not like without SSAO Pro.

    I saw in this thread an answer about transparancy problem but this solution looks to be related to shader forge.

    Any help would be welcome :)
     
  46. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    That's weird, SSAO Pro shouldn't affect particles at all as it's rendered before transparent objects and Particle/Additive is in the transparent queue... What Unity version are you running ?
     
  47. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
    5.3.3
    Without SSAO Pro I have my beautiful torch as I created it, and when I enable SSAO Pro it becomes half transparent, but only in one side.
    I mean if I look it in front it is half transparent, by the side it has it normal look.
    As I said the "Soft particles Factor" put at maximum corrects mostly the problem, but if we look at it we can clearly say which side is the good one.
    Thx for the answer by the way :)
     
  48. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
  49. fairtree

    fairtree

    Joined:
    Jun 11, 2012
    Posts:
    84
    In quality settings I disabled "Soft particles" and now it works as it does.
     
  50. Chman

    Chman

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    721
    So somehow SSAO Pro affects the rendering of soft particles... Weird. Did you try with the default SSAO effect that comes in the Standard Assets package installed with Unity ? Does it also affect soft particles ?