Search Unity

Horizon Based Ambient Occlusion - HBAO image effect

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

  1. CmartinezSaltoki

    CmartinezSaltoki

    Joined:
    May 21, 2020
    Posts:
    10
    Another thing I was wondering is if there's anyway of adjusting HBAO intensity depending on the object it is affecting. e.g. I want my sofa to have a very noticeable HBAO while in the walls is barely apreciable.
    Would that be possible?
    Thanks again!
     
  2. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    For the same reason as previously this is not possible, HBAO is not aware of your objects. Without a complex prepass system that would ruin all performances all this is impossible.
    But you could bake AO on these objects were you want more occlusion, HBAO will apply on top of it.
     
  3. CmartinezSaltoki

    CmartinezSaltoki

    Joined:
    May 21, 2020
    Posts:
    10
    Thanks one more time!
    I'll mess around with my project and if I bump into some more questions I'll post them here!
     
  4. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    230
    Do you know what could make HBAO (2.9.0) render these 'shadow acne' type artifacts on an iOS build?

    Edit: Upgraded to 3.2.0, same issue.

    (it's all fine on Standalone/Mac)

    IMG_A82FABCF14CF-1.jpeg
     
    Last edited: Jun 1, 2020
  5. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Hello,

    I recently purchased the plugin and am trying to make it work. I'm using 2019.3 unity, URP, attached the script to the camera, but nothing happens -not in preview, not in game, not in build.

    I did the URP settings mentioned in the user guide to no avail.

    I'm not sure what info I have to provide but I can't even seem to get the demo working. any idea what may be wrong, after I did all the settings in the UG?
     
  6. GridWanderer

    GridWanderer

    Joined:
    Dec 14, 2014
    Posts:
    12
    Hi @noio - this relates to a known issue with URP 7.3.x and below. The fixes for this are not yet rolled out for URP for Unity 2019 (but hopefully will be in an upcoming URP 7.4.x release, otherwise may need to upgrade to Unity 2020 to gain access to these fixes in URP 8.x.x). I can verify that merging the changes referenced by @jimmikaelkael in post #599 into URP v7.3.1 fixed this issue for me.
     
    jimmikaelkael and noio like this.
  7. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    230
    I was having an issue getting it to work earlier too. Two things:

    1. I don't think you have to attach the HBAO script to the camera when you're using SRP. You just need a Volume and the RenderFeature on the URP config.
    2. I was forgetting to set the volume/camera to the correct layer.

    Oh, awesome! Going to try that!
     
  8. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Hi noio, thanks for your reply.
    I'm very new to the rendering aspect of unity so I'm asking to be clear.
    When you say "you just need a volume", you mean like I have to assign a volume to the camera and that's it?

    and how do I set the volume/camera to a correct layer? what's the correct layer :D (sorry for my ignorance)
     
  9. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    These are the things I did:
    - set SRP to URP Medium in graphics settings
    - add HBAO as a renderer feature
    - set renderer depth texture to true
    - set camera post processing to true
    - set hbao to the camera, to no avail. deleted.
    - create a global volume, set its layer the same with the camera, add post processing layer to the camera, add hbao to the volume, to no avail, deleted.
    - add post processing volumes/layers to various objects, to no avail.

    there's probably something very simple that I'm missing.
     
    Last edited: Jun 2, 2020
  10. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Yes, once you added hbao to your volume, check the warning that says you should raise intensity to enable effect.
     
  11. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Thanks for the info. I managed to get it working in unity, but when I export to WebGL, there is no AO.
    I can see it in the preview, and the game build inside unity (so my camera is working and using post processing) but when I export, nothing.

    Is there a setting to make it work with WebGL?
     
  12. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Please check post #626
    Currently Unity is completely disabling PP in GLES2.
     
  13. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    I tried it but couldn't make it work.

    just to be sure, these lines will be commented, right?

    anyPostProcessingEnabled &= SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2;

    and

    cameraData.postProcessEnabled &= SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLES2;

    I did that but it still doesn't work. great AO in preview, none in the build. (I see that it calculates HBAO stuff during the build)

    unity version 2019.3.11f1 <DX11>
     
    Last edited: Jun 2, 2020
  14. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Yep, not sure what you're doing. Anyway, Post Process is being disabled in GLES2.0. Not much I can do for that and I'm really sorry, it is up to Unity.
    In standard pipeline HBAO supports GLES2.0 and last time I tried myself to enforce it in URP it worked, give it some time and I'm sure Unity will enable post process on GLES2.0, there's no reason they don't.
     
  15. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Hmmm...

    well then, what's the version of unity that this actually worked? I'll download it and give it a go.
     
  16. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    2019.3.13f1 with URP 7.3.1
     
  17. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    For some reason, this did the trick.

    Thanks for helping out.

    Still, unity is really weird :)
     
    jimmikaelkael likes this.
  18. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Yes, don't worry I'm sure they will enable it back in GLES2 soon.
     
  19. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Another question,

    is it possible to prebake the AO ?
     
  20. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Unfortunately, no.
     
  21. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    Hi, I'm using HBAO for a WebGL project. It works fine in the editor, but I get pass index errors at runtime :

    Code (CSharp):
    1.  
    2. RenderingCommandBuffer: invalid pass index 6 in DrawMesh
    3. RenderingCommandBuffer: invalid pass index 8 in DrawMesh
    4. RenderingCommandBuffer: invalid pass index 11 in DrawMesh
    5.  
    I included the HBAO shader in the Always Included Shaders list and I'm not stripping it.

    I'm on Unity 2018.4.18f1.

    Any idea what's happening ? I was using SSAO from the post processing stack until then and it was working with both WebGL 1.0 and 2.0.
     
  22. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    HBAO in Standard pipeline works fine with WebGL 1 and 2.
    Most likely you updated from an older release, please delete HBAO package completely as well as the component on your camera then reinstall it.
     
  23. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    When installing last HBAO package, I get errors related to XR because XR is completly disabled in my project. I removed all the code in HBAO that related to VR. This include the first ENABLE_VR block of FetchRenderParameters(). The symbol ENABLE_VR is not defined in my project.


    The demo scene file works correctly in WebGL. There must be something wrong somewhere else which is not directly related to HBAO.

    Thanks for your help and your package :)
     
  24. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    I got HBAO working in WebGL. But I get artifacts:



    I suspect this is coming from the noise texture ? These artifacts are visible in the demo scene as well.

    EDIT : By looking at your demo, it seems blur is not working in my case. I will check that out.

    EDIT : I placed the HBAO first on my camera, as stated in the docs, and it works :)
     
    Last edited: Jun 8, 2020
  25. menguzat

    menguzat

    Joined:
    Aug 20, 2017
    Posts:
    15
    Hi again,

    I'm planning to use unity 2020 for a new project. Any idea about HBAO - URP - WebGL stuff in unity 2020?
     
  26. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    Hi,


    we have a question regarding your HBAO unity plugin.

    We find out that when adding HBAO to the camera the drawcall count (e.g. batches measured in unity) is exploding.

    It is not doubled, it is 4-6 times more than without the effect.
    When disabling it, the drawcall count does not go back as it was before.

    Can you tell us why this is, and maybe how we can decrease it (doubling the drawcall would be okay, but not as much as it is now)?

    We are using the forward rendering method of the camera (Legancy render pipeline) with unity2019.4.0f1 and your newest version of the HBAO plugin.

    Thank you very much.
     

    Attached Files:

    • 01.jpg
      01.jpg
      File size:
      373.4 KB
      Views:
      358
    • 02.jpg
      02.jpg
      File size:
      408.2 KB
      Views:
      365
    • 03.jpg
      03.jpg
      File size:
      403.7 KB
      Views:
      357
  27. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I'm sorry but this is expected, HBAO relies on Depth and DepthNormals textures which in forward rendering does not comes free. In your case HBAO itself is eating 5 drawcalls, other batches are for generating depth and normals textures which continues to be generated when you disable HBAO.

    I suggest reading this: https://docs.unity3d.com/Manual/SL-CameraDepthTexture.html
     
  28. camta005

    camta005

    Joined:
    Dec 16, 2016
    Posts:
    320
    I'd recommend switching to deferred rendering as it will solve the problem. Then make sure 'Per Pixel Normals' is set to G Buffer or Camera (not Reconstruct).
     
    jimmikaelkael likes this.
  29. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    Is there a way to disable that, as I am assume if the HBAO effect is turned off (or the component is removed), the old drawcall count should be present again.

    Regarding Depth textures in forward. Do you know if it is possible to have also GPU Instancing for the Shader-Replacement (normals, depth)? That would also help I guess?

    Thank you for the tipp, we'll check.
     
  30. Zapan15

    Zapan15

    Joined:
    Apr 11, 2011
    Posts:
    186
    We will give Camera.depthTextureMode a try :)
     
  31. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Nope, there’s no good way to automatically disable depth texture rendering if you disable an individual post effect. Again, please check https://docs.unity3d.com/Manual/SL-CameraDepthTexture.html, Tips and Tricks paragraph.
    You can create script to turn off the requested flags when you disable HBAO.
    HBAO cannot assume it is the only post process used so it can't do it itself.

    I'd not care about it, especially if you switch to deferred rendering path.

    This is out of the scope of HBAO. Again, we encourage you to switch to deferred if your target platfrom allows it (https://docs.unity3d.com/Manual/RenderingPaths.html, bottom paragraph).
     
  32. joedanimation

    joedanimation

    Joined:
    Dec 30, 2017
    Posts:
    3
    I'm so glad to see VR support added for the standard render pipeline. Do you have a timeline for VR support with URP?
     
    jeromeWork and wingcutangel like this.
  33. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Hello, I have a camera stack using Universal Render Pipeline 9.0.0, Unity 2020.1 and multiple post processing volumes.

    HBAO works well if I have one camera that's set to "base", but it doesn't work in the stack (even on the base camera, and also not on the overlay cameras). Any ideas?

    upload_2020-7-19_22-38-52.png

    The debug feature works on the Overlay camera, but there's no AO. (the object is in the overlay's culling mask, but not in the base camera's.)

    If I make the bottom camera render everything, it "works" (but that requires the base and the overlay camera to render the same culling masks, and look the exact same direction, which defeats the purpose of overlay cameras). I want the AO to be generated especially (actually exclusively) for what the overlay camera sees, because that's the foreground.

    upload_2020-7-19_22-40-14.png
     
    Last edited: Jul 19, 2020
  34. magnussen81

    magnussen81

    Joined:
    Mar 8, 2019
    Posts:
    7
    Hi, quick question; If I'm using HDRP do I need anything other than the embedded HDRP package - can I skip the "default" assets when importing?
     
  35. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Hi, I'm sorry but here is summer holidays so I have no timeline but what's sure is that next release will have VR support for URP.

    Thank you very much for report, I will look into it.

    Yes, it should work without default assets.
     
    jeromeWork likes this.
  36. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    There seems to be a bug with Unity 2020.1 and latest URP that will cause Gfx.waitforpresentongfxthread to use up almost 50% of CPU while HBAO is active. Problem went away after disabling HBAO. Is this something you are aware of?
     
    amynox likes this.
  37. magnussen81

    magnussen81

    Joined:
    Mar 8, 2019
    Posts:
    7
    Thank you very much for responding here.
    I have another questions (or maybe request if possible); In the documentation you write that HBAO can be injected at various stages in the pipeline but in HDRP is seems locked? I'm not a programmer so I won't really dive into it but I would like the effect to come before (volumetric) fog if possible.
    And thank you for at great asset!
     
  38. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Hi,
    As i'm using Unity 2020.1 and latest URP version, would love to know if this bug is still present in the current release before purchasing this asset.

    Thank you
     
  39. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Yes its still present. Ive had to disable this asset for now.
     
    amynox likes this.
  40. alextee103

    alextee103

    Joined:
    May 27, 2017
    Posts:
    7
    everything in unity works fine but no matter what i cannot get HBAO to show up in my game :(
     
  41. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    No, I'm sorry. Tried Unity 2020.1.2f1 and URP 8.2.0 up to 9.0.0-preview.35 and I cannot reproduce this problem.
     
  42. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Injection stage on default pipeline has never been a way to order your post processes... I understand it might help, but that's not what you want.
    Actually HDRP has only custom post process effect sorting, I think they will add this at some point.
     
  43. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Not sure you're the person who mailed me, so I'm making assumption it's under HDRP. Tried Unity 2020.1.2f1 and HDRP 8.2.0 and I cannot reproduce it.
    Please ensure to read the documentation for proper setup.
     
  44. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Yup this seems fixed in 2020.1.2f1.
     
  45. hellstorm

    hellstorm

    Joined:
    Jun 29, 2015
    Posts:
    41
    Greetings, using this in VR i get the error

    A multisampled texture being bound to a non-multisampled sampler. Disabling in order to avoid undefined behavior. Please use Texture2DMS in the shader.


    it looks like debug mode when i press play in vr, all white and just showing ao.
     
  46. hellstorm

    hellstorm

    Joined:
    Jun 29, 2015
    Posts:
    41


    this is MSAA, i cant seem to use it with HBAO and VR
     
  47. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Actually the problem doesnt rly seem fixed. With HBAO I run my game at roughly 100FPS, without HBAO it goes up to 230 FPS. And most of it has to do with Gfx.waitforpresentongfxthread. It is 100% due to this asset, since simply disabling it fixes everything. Do u want me to send u some specifics so you can diagnose it?

    The more i zoom in the game view, to worse it gets, I get these spikes:

    upload_2020-8-17_22-21-31.png
     

    Attached Files:

  48. leslviv

    leslviv

    Joined:
    Jun 22, 2019
    Posts:
    32
    Is it works with PPV2?
     
  49. melos_han_tani

    melos_han_tani

    Joined:
    Jan 11, 2018
    Posts:
    79
    Hi! First, love the plugin, the features are very artist-friendly and well-documented. I'm using this with URP on Unity 2019.4.

    I glanced through the thread and am pretty sure the answer is no, but I wanted to check: there's no way to leave particular layers of objects out from the AO, right? (I read you say this plugin doesn't allow you because of performance reasons.) I was wondering because I noticed that on some settings, AO draws between the player and the floor and it looks like an odd halo (see the feet) - however - I'm not the artist, so it's possible whatever settings end up being used wouldn't even create this 'halo' to the extent it'd be an issue. (I'm just asking ahead of time). Thanks!

     
  50. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I don't see a problem at my end but I don't understand why you aren't profiling GPU...
    Your CPU is awaiting GPU to finish its job. Keep in mind that when HBAO is enabled you request for depth texture rendering which can also be used for other post process and this will have a cost.