Search Unity

Horizon Based Ambient Occlusion - HBAO image effect

Discussion in 'Assets and Asset Store' started by jimmikaelkael, Feb 21, 2016.

  1. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    Looks like you have another script named Slider. Either go in front of the variable declaring slider and put UnityEngine.UI.Slider instead of slider or you can do
    Code (CSharp):
    1. using Slider = UnityEngine.UI.Slider;
    with the usings in the slider.
     
    jimmikaelkael likes this.
  2. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    426
    thx for answer
    seems like we have such another script. project is veeery big. and im not a programmer =(
    well... im not using hbao demo so... i just deleted it =) helped too
     
  3. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    As @Stormy102 suggested, you could edit HBAOControl.cs script and change line 7 to:
    Code (csharp):
    1.  
    2.     public UnityEngine.UI.Slider aoRadiusSlider;
    3.  
    Deleting the "Demo" folder as you have done works too.
     
    Stormy102 likes this.
  4. Mike_Fibo

    Mike_Fibo

    Joined:
    Jul 13, 2016
    Posts:
    2
    Hi. Updated to the latest HBAO version on Asset Store, and on WebGL platform I have "HBAO shader is not supported on this platform". Any workaround?
     
  5. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    If you're talking about HBAO_Integrated component I don't think it's supported on WebGL, however the legacy HBAO component should.
    I'll check this all once at home.
     
  6. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Just tried WebGL platform both in editor and in build (Unity 5.5.1f1), both HBAO and HBAO_Integrated works fine so I can confirm it works fine with WebGL.

    EDIT: I suggest you to delete HBAO package folder completely from your project then reimport it. Let me know if the problem persists.
     
    Last edited: Mar 15, 2017
  7. Mike_Fibo

    Mike_Fibo

    Joined:
    Jul 13, 2016
    Posts:
    2
    Yeah, I've started the new project, imported - works fine, without any trouble. Thanks for help, and sorry for your time.
     
  8. games_lam

    games_lam

    Joined:
    Nov 2, 2015
    Posts:
    8
    Hi, is there a way to exclude certain objects from this effect?
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    You can force a render queue by changing your inspector to debug mode (right click on inspector panel title, then select debug).

    Once done, with the unity explorer, go on your object material, you'll see a "Custom Render Queue" setting which should be at -1 by default.
    If you change this to be right after opaque materials it should be good, so try to set a value of 2510 for example.

    After that you can leave inspector debug mode.
     
    games_lam likes this.
  10. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Hi there. I have a major issue with the way this asset handles the radius of the AO on different resolutions.
    For example if I set the radius to 2 and max pixel to 256 on a 1920x1080 viewpoint the AO looks wide as intended.
    When I use the exact same settings at 4K, the AO becomes thinner and sharper, like it is half the radius of the 1080p version.

    I believe this is because the 'max radius pixel' can only be set at a maximum value of 256. But I would like the 4K view to have the same radius as the 1080p view did. Maybe it is better if you allow us to input any value we want for max radius pixel, or instead of an absolute value, change it to a percentage? Or disable/enable max radius pixel?

    You can replicate this by simply have any scene open and have the radius and max pixel slider maxed out, then create custom resolutions for the editor's Game preview as 1920x1080 and 3840x2160. Then you will see that at 4K the AO becomes much thinner than the 1080p one.

    All other AO assets are consistent on every resolution.

    Thanks
    -Paul
     
  11. Stormy102

    Stormy102

    Joined:
    Jan 17, 2014
    Posts:
    495
    I find this with other image effects too - SE Natural Bloom has a much reduced bloom too. Not sure if it's a Unity issue or if it's fixable by asset store authors.
     
  12. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Yeah I understand the problem, the radius is expressed in world units so this fits perfectly for 4K. The radius cap is there to prevent close up view to eat too much calculation so it is quite important, and I think best the best solution is just to increase this max radius limit. It could be proportional to screen resolution but honestly I prefer to let it as a setting.

    I'm released an update in the next few days so I'm applying that change right now.
     
    Stormy102 likes this.
  13. paulHouard2017

    paulHouard2017

    Joined:
    Mar 29, 2017
    Posts:
    3
    Hi, I have a problem with Speedtrees, where the effect is not taking in account the transparency, and in consequence, is showing the real polygons as shown on the picture.
    I can tweak the focus and when the focus is low, then the artifact is gone, but the HBAO effect is gone too.
    I have read that it is related to being in forward mode and that the depth buffer is not managed correctly by Unity.
    I cannot use deferred, so is there any solution to remove these artifacts?

     
  14. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Try to use the HBAO_Integrated component instead. It is less prone to this kind of problems.
     
  15. paulHouard2017

    paulHouard2017

    Joined:
    Mar 29, 2017
    Posts:
    3
    The picture is made with the Integrated component. Either I remove the artifact and the AO is barely noticeable, or I get these that are annoying specially when flying over :(
     
  16. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    The Reconstruct "Per Pixel Normal" mode in AO settings should solve the problem. I'll try to see if I can do something for the other mode.
     
  17. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    This is your last chance to get the asset at reduced price as version 2.2 is pending review and back to normal price (this is not April's foll I'm sorry ^^).

    v2.2 changelog:
    • HBAO_Integrated: adjusted to avoid any per frame GC allocation
    • Increased Max Radius Pixels limits to be compliant with 4K resolution
    • Prefixed radius Slider control variable type with namespace to avoid potential ambiguity
     
    turboscalpeur and Stormy102 like this.
  18. docsavage

    docsavage

    Joined:
    Jun 20, 2014
    Posts:
    1,011

    I still totally recommend this over the new unity post processing effects. Never had an issue with it and it looks very nice:)
     
    jimmikaelkael and turboscalpeur like this.
  19. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    v2.3 has been released today with minor fixes for Unity 5.6:
    • Fixed Camera.hdr obsolete warning
    • Fixed inconsistent line endings warning in HBAO.shader
     
  20. steveboeters

    steveboeters

    Joined:
    Jun 16, 2016
    Posts:
    2
    As single pass stereo rendering hasn't been implemented yet, I just want to make people aware that the solution here works fine.

    Although I don't know how to get it working with the integrated version.
     
    jimmikaelkael likes this.
  21. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    I don't think it is the proper way to go... Have you checked the AO output is really correct with this ?
    I mean without blur do you really have a clean AO ?
     
  22. steveboeters

    steveboeters

    Joined:
    Jun 16, 2016
    Posts:
    2
    The AO output seems to be the exact same. On the highest quality preset (with reconstruct on) I have significant dithering on intense spots but that is with both cases.

    Sorry, I am not in the position to share screenshots of what I am working on.
     
    jimmikaelkael likes this.
  23. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Hi, is it possible for the trial package to be updated too? I wanted to see the performance difference between version 1.7 to 2.2 which introduces a higher Max Radius Pixels. I am currently experimenting with various trial assets in the Unity store before starting my project later this year.

    I also wanted to report a small graphical issue: when you place grass using Unity's terrain editor then enable HBAO in deferred and G-buffer mode, you can see AO through the grass, that means things like character's feet and rocks are clearly visible. I tried other AO solutions such as VAO which also uses the G-buffer with no issues (though I love HBAO more!)

    Here are some screenshots for comparison, pay attention on the grass, and you can see the settings on the right. I am in Deferred rendering mode.

    HBAO Disabled, looks normal.
    a0.PNG

    HBAO Reconstruct, looks good, nice AO on the cave ceiling and grass, but I want G-Buffer.
    a1.PNG

    HBAO G-Buffer, you can see the rocks through the grass, but the cave ceiling looks nicer.
    a2.PNG

    You can replicate this in a new scene, have a small square plane terrain, place a cube in the centre then add tall grass around the cube. Point the camera at the cube similar to the screenshot above, use deferred rendering, then enable HBAO with G-buffer.

    The reason I need G-buffer as it takes normal maps into consideration while Reconstruct ignores normal maps.

    Kind regards,
    -Paul
     
  24. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    I do appreciate your report, but it is obsolete as it is based on this outdated demo and I apologize for this...
    In 1.8 release I fixed an important problem concerning rendering path detection (please take a look at the changelog on 1st post).

    This problem does no longer exists, and I'll do my best to update the trial version.

    EDIT: Trial package updated to v2.3
     
    Last edited: Apr 28, 2017
    ApolloPM likes this.
  25. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Hi there, the Trial package v2.3 seems to still have the same issue. In the screenshot below you can see it's v2.3 as I cranked Max Radius Pixels to 512.

    b1.PNG
    I have tested in various resolutions, moving HBAO up/down the processing stack and disabling other camera scripts, tried the various options in the HBAO_Integrated version, it did not made a difference.

    In other news, I found changing Max Radius Pixels from the absolute lowest (64) all the way to (512) only impacts performance by 3-5% in 1080p and 4K on a mid-range GPU. This is a very well optimised asset.

    Kind regards,
    -Paul
     
    Last edited: Apr 28, 2017
  26. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Debug Screenshots

    Reconstruct
    b2.PNG

    G-Buffer
    b3.PNG

    EDIT: These viewport resolution are in 4K, previous post was in 1920x1080 thus why the watermark banner on top right corner got smaller.
     
  27. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Still can't reproduce it...
    Normal terrain ? what's the rock material shader ? Is it grass detail placed as texture on the builtin terrain editor ?

    Is it possible for you to send me a small repro project with a simple scene ?
     
  28. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Yes the terrain is just the built-in Unity terrain editor and I just add the grass from the Standard Assets>Environment>TerrainAssets>BillboardTextures. The rock shader I created from scratch but switching it to the standard shader doesn't make a difference.

    The "see through" issue is not just for the rocks, it is for every object in the scene including the character's feet which just uses standard shader.

    I uploaded the project folder via a Google drive link to your email (jimmikaelkael@gmail.com). The scene you want to open is "ShaderTest" (there is only one scene anyway). The folder structure look messy since I am just experimenting with various trial and open source assets and how it works with my own assets, I apologise for that.

    I am still on Unity 5.5.0f3 though I don't think that is the issue since I have this problem since 5.3.

    Correction: The 2D grass in this project is made by me, swapping it with Unity's asset grass billboard texture doesn't make a difference.
     
    Last edited: Apr 29, 2017
  29. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Here is a much simplier scene that you may replicate from scratch. Just flat terrain with grass and a cube.
    Reconstruct
    c1.PNG
    G Buffer
    c2.PNG
     

    Attached Files:

    Last edited: Apr 29, 2017
  30. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    OK, I see the problem now.
    The builtin terrain grass shader doesn't write to GBuffer as it excludes the deferred path... Every SSAO solution relying on GBuffer will exhibit this see-throught problem, try too with VAO setting GBuffer Normals and you'll see.

    The PerPixelNormals settings you want to use here is "Camera", the grass shader does write to the CameraDepthNormals texture so it will work and you'll get texture normals AO.
    You can as well use the rendering pipeline integrated HBAO but in this case set its integration stage as "Before Image Effect Opaque".

    EDIT: You too have the solution to use the attached grass shader I've modified to use deferred path. Simply drop it in your project folder and reload unity (Please note this will not work with grasses with 'billboard' option ticked, in this case we need to modify another shader, let me know if you're interested). The use of this shader should lower your batches and tris count as well.

    Before using the deferred grass shader:


    After:


    HBAO only:
     

    Attached Files:

    Last edited: Apr 29, 2017
  31. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    Ah yes thank you very much, your shader has fixed everything.
    Will be using HBAO for the project when the time comes.
     
  32. pointcache

    pointcache

    Joined:
    Sep 22, 2012
    Posts:
    551
    hello, thank you for creating this amazing effect, i am using it for a long time without problems,
    i have an issue with current project tho

    Is there any way to exclude the terrain from ao, so it doesn't leave these lines?
     
  33. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    274
    I'm trying to try out the demo of this asset, but it won't compile. It says "The type or namespace name 'HBAO_Trial' could not be found." Does anyone have any advice? I'd really like to be able to try this while it's still on sale.
     
  34. ApolloPM

    ApolloPM

    Joined:
    Mar 24, 2017
    Posts:
    12
    I fixed this issue by going to Assets > Horizon Based Ambient Occlusion > Scripts > Plugins > HBAO_Trial.
    Click on "HBAO_Trial" file then on the Inspector tick "Any Platform" then tick all the boxes under "Platform settings"
    123.PNG
    EDIT: Make sure you hit Apply.
     
    jimmikaelkael likes this.
  35. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Is this with unity builtin terrain ? Which shader ?
    It seems you have a lot of discontinuities on your mesh, how is this one made ?
     
  36. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    I wasn't aware of this issue... Please try what @ApolloPM suggested above.
    FYI the full version is provided with full source code and so there's no native plugin necessary.
     
  37. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    274
    Got it working. Thanks!

    It looks great, too. Probably the winner out of the many, many ambient occlusion assets I've tried today. Looks very

    I'm impressed with how color bleeding looks with bright emissive surfaces, but I'm not sure about it everywhere else. Is there any way to only bleed pixels brighter than a certain threshold?
     
  38. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Sorry for the late reply... Isn't the "albedo multiplier" under Color Bleeding Settings (only available in deferred) is enough to control this ?
     
    Howard-Day likes this.
  39. brisingre

    brisingre

    Joined:
    Nov 8, 2009
    Posts:
    274
    Okay so: I didn't actually end up buying this. It looked really good in my test scene, which is very confined, but I didn't love it on my main scene which has much longer site lines and lots of big flat polygons. (I've never seen an SSAO solution that handled this particularly well. Either I can't turn up the spread enough to get smooth-looking edges, like with this one, or when i do turn it up high enough it causes hella other problems because SSAO really isn't meant for this kind of geometry. )

    Perhaps I'll come back someday, I have other projects where SSAO isn't as much of a lost cause, but currently I'm not a customer & you don't need to support me.

    That said, Albedo Multiplier doesn't do what I was looking for. If I set it to 0, it turns off color bleeding entirely, even from emissive surfaces. If I set it any higher, I get bleeding everywhere, even off of surfaces lit only by ambient light. This doesn't look bad, per se, but overall I like the look of the effect more with color bleeding off.
     
  40. mekjal

    mekjal

    Joined:
    Aug 14, 2013
    Posts:
    7
    I have the same problem as @pointcache - is there a solution or way to exclude the terrain?
     
  41. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    This means you want PBR lit AO. You need to use the HBAO_Integrated component in deferred and set integration stage to "Before Reflections".
     
    brisingre likes this.
  42. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    The short answer is no. Which terrain type is it ?
     
  43. Carpet_Head

    Carpet_Head

    Joined:
    Nov 27, 2014
    Posts:
    206
    Do you think this will ever work with single pass stereo rendering?
     
  44. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    This is true I'm late with this feature, but sure this is planned that I support this.
     
  45. KillerNads

    KillerNads

    Joined:
    Jan 22, 2017
    Posts:
    70
    Hi Guys,

    Saw this HBAO on sale today on the unity store and was interested in purchasing it.

    Im making a Desktop VR game, i wanted to know if this asset will benefit my game in any way? Or if it won't make a difference in a VR game?

    Thanks.
     
  46. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    Yes this effect works with VR and of course have noticeable visual result.
    However it's not currently compatible with SPSR (which is still planned) so it can be a bit costly with VR.

    Anyway just try the trial package and make yourself an idea: https://drive.google.com/open?id=0B0gnjB7PN1h3Y09Tcm9pWEtLNGc
     
  47. KillerNads

    KillerNads

    Joined:
    Jan 22, 2017
    Posts:
    70
    Thanks for the instant reply back. Sorry for sounding like such a beginner (which i am actually :D) but what is SPSR? When is the feature going to be added by?

    Lastly, what does HBAO actually do, does it help with Jaggy edges? or is it more of a lighting technique which helps the shadows of objects, because thats really all i could see from the comparison images on the asset store. Again i apologise for being such a noob!
     
  48. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    SPSR is Single Pass Stereo Rendering, simply put it allows to avoid to do the job twice for both eyes.

    HBAO is a form of SSAO, it will not remove your jaggy edges (this is not Anti-Aliasing solution).
    HBAO will reproduce light atenuation due to occlusion, giving your brain more visual clues on the depth. Basically this is approximating Ambient Occlusion by determining the angle of free horizon around the hemisphere aligned with the tangent plane of the point being looked at, this involves a bit of raymarching the depth buffer.
     
    KillerNads likes this.
  49. KillerNads

    KillerNads

    Joined:
    Jan 22, 2017
    Posts:
    70
    Ah right, that makes more sense to me thanks!

    Do you have an idea when the SPSR feature will be added? I guess if this helps with visual clues on depth then it must be a very useful feature to have especially in a VR game! I assume this would work quite well with something like Beutify to provide a much better image?
     
  50. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    653
    I have no ETA for it, I'll do my best to bring it asap but I can promise any date... The main problem being that I do not own a VR device currently to try it myself.

    HBAO, like any other SSAO solution is meant to be a subtle effect, If it's overdone it can look bad. The effect have an rendering pipeline integrated component (HBAO_Integrated) which can be used to do PBR lit AO (using "Before Reflections" integration stage) and is more physically correct.

    Try the demo package ;) you will see yourself how it looks like. The only limitation in the trial package is no source code from scripts and a watermark.
     
unityunity