Search Unity

Horizon Based Ambient Occlusion - HBAO image effect

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

  1. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    So now it's clear that it's URP that is stripping SSAO functionality from shaders.

    The workaround is quite simple, but first make sure that you set rendering path under HBAO settings to deferred, then apply the workaround I've previously given: https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-22#post-8333814

    Be careful: when you create this dummy renderer to attach Unity's SSAO to it, make sure you set its rendering path to the same path that your default renderer with HBAO. In your case Deferred.
    If this dummy renderer is not created with same rendering path then URP strips shaders SSAO functionality.
     
  2. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Why does the background reder in black, rather than the solid colour I chose for camera, when I disable the XR package? I believe it is HBAO related since the background renders fine again when I disable HBAO in render features.

    Unity 2022.2.1, URP. I have two cameras with one set as overlay and to ignore volumes.
     
  3. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    You can confirm it is HBAO by trying with Unity's SSAO renderer feature, if the problem happens too with builtin SSAO then it's a global renderer feature issue.

    I tried to reproduce but no luck, if you can confirm it's only with HBAO please send me a repro project so that I can investigate.
     
  4. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,148
    Added SSAO, disabled HBAO, and disable XR package, and background renders with chosen colour. Enable HBAO in Render Features and background goes black.

    [Edit] Just tested in clean 3D URP project. As soon as I remove the VR and XR packages the camera background colour becomes black. Note, background type = Solid Colour, not Skybox. Skybox still works fine.

    I think this is specific to 2022.2. A 2021.3 project worked fine with XR removed.
     
    Last edited: Jan 9, 2023
  5. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Thanks for feedback, it's not HBAO. I was able to reproduce in fresh project without any asset. It's a general URP issue.

    I filed a bug report with a repro project (CASE IN-28267) with following details:
    I attached the repro project to this post.

    EDIT: fixed in 2022.2.6f1
     

    Attached Files:

    Last edited: Feb 12, 2023
    Leslie-Young likes this.
  6. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    I'm trying to use HBAO with VertExmotion, but the HBAO is producing a strange outline which shows the mesh both before and after deformations from VertExmotion. Any idea how I can work around this?

    I'm using per "pixel normals: reconstruct" to alleviate this, but the character mesh becomes quite unsightly, so I don't see myself using this solution for long.
     
  7. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Never used this asset so I don't know. It seems to have issues with some SSAO solutions:
    https://forum.unity.com/threads/vertexmotion-released.277294/page-12#post-3552107
    https://forum.unity.com/threads/vertexmotion-released.277294/page-14#post-4075042

    Like most SSAO solutions, HBAO require 2 inputs: depth and normals textures that Unity provides to shaders. An exception is Reconstruct mode which only uses depth as input.
    So, if both depth and normal textures were reflecting correctly the shape of your mesh (which is expected in all cases of course) there should not be any issue.

    See with VertExmotion developer, maybe there's a specific configuration. This is not an issue in HBAO.
     
  8. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    Thanks for the quick reply. I wasn't suggesting it's a bug with either HBAO or VertExmotion, just pointing out the clear incompatibility of the two assets.

    Was merely wondering if it could be something simple like an ordering issue, but tried setting HBAO higher in the script execution order and no luck.
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    You cannot change rendering order of HBAO like that because it's using command buffers.
    If you are in deferred redering path you could try to change "pipeline stage" setting in HBAO, in general settings to AfterLighting or BeforeReflections. BeforeReflections does lit AO but AfterLighting is the latest stage possible in the pipeline.
     
  10. Graham-B

    Graham-B

    Joined:
    Feb 27, 2013
    Posts:
    331
    HBAO is now working perfectly with VertExmotion. For anyone else who runs into this compatibility issue, the solution is simply enabling "Vertex Buffer" mode in the VertExmotion editor panel. This works in Unity version 2021.2 and newer.
     
  11. MayhemGamingYT

    MayhemGamingYT

    Joined:
    Sep 21, 2017
    Posts:
    3
    HBAO is causing my player to have a weird glow effect. I'm using HDRP on unity 2021.3.15. Anyone have any idea why?
    Screenshot 2023-02-06 145918.png
     
  12. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    16
    Hi, is it possible to use HBAO to achieve an effect that looks like the inverse of ambient occlusion - adding highlights to areas, similar in appearance to a convexity map? Many thanks!
     
  13. Plumpman

    Plumpman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Hello! The HBAO is working great on Windows and Mac, but on my Linux builds it doesn't seem to be rendering correctly ( I can see the HBAO on screen, not matching the 3D objects positioning). Is their something I'm forgetting to set for Linux to work?
     
  14. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    You should not have to change anything...
    Please let me know, which Unity version, which render pipeline, which graphics API and which Linux distribution you are using so that I can do some tests when I can.
     
  15. Npicouet

    Npicouet

    Joined:
    May 17, 2018
    Posts:
    30
    Sure thing! (Sorry same person, dunno why it swapped profiles)

    Unity Version 2021.3.17f1 (Silicon Mac M1)
    URP 12.1.9. Forward Renderer.
    Running on Steam Deck, so whatever the latest linux distro is for that.
     
  16. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Well, I have no such device...
    I don't see any fault in HBAO code, it's referring to camera texture descriptor provided as parameter by ScriptableRenderPass's Configure method override.

    Could you try with builtin SSAO renderer feature instead and see if it is the same?
     
  17. JerryComo

    JerryComo

    Joined:
    May 23, 2022
    Posts:
    10
    Hi - I'm on 2021.3.18f1 URP pipeline - building for ios & droid and I can't get the AO appearing. It *does* work on mobile when I set the debug mode to AO only though. Also displays fine in the editor (in non-debug mode)

    I've tried multiple options in the URP, Camera and Volume settings with no success. Has anyone else had this issue.
    Looks great in the editor btw.
     
  18. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Seems like it is URP shader stripping issue, see this post for a workaround:
    https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-22#post-8333814
     
    JerryComo likes this.
  19. JerryComo

    JerryComo

    Joined:
    May 23, 2022
    Posts:
    10
  20. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Debug mode worked because that's not HBAO that is being stripped. When you build without builtin SSAO being included, URP is strpping shaders from SSAO functionality, it's not aware you are using a 3rd party AO.
     
  21. hschulte

    hschulte

    Joined:
    Oct 2, 2018
    Posts:
    12
    Hello,
    I'm writing because of the incompatibility of HBAO with MSAA in HDRP. We were in contact with the Unity Engine support and told them about your claim that this is a bug in Unity. This was their response:
    No sure if you already did open a ticket, but I feel it might be worth it.
     
  22. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Hahaha... Easier to tell the issue is in HBAO...

    Even the dummy PP component I'm attaching below is reproducing the issue (2020.3.0f1), it does nothing else than just blitting source to destination using Render method override parameters. To test it you need to add the effect to custom post processes order setting.

    I doubt it was never reported to them so their comment sounds rather unfair...

    Anyway, I will not report since it has been fixed in later versions (does not reproduce in 2022.2.0f1).
     

    Attached Files:

  23. vchedeville

    vchedeville

    Joined:
    Jun 1, 2022
    Posts:
    5
    Hi,
    In the project I'm currently working on, we are using a decal system with a mesh plane. However, we are facing a problem where the Ambient Occlusion is calculated on the side of the decal plane, creating a dark outline. I would like to know if there is a solution to either remove the AO calculation from certain meshes or prevent the AO from being calculated on the transparent surface.
    Thanks
     

    Attached Files:

  24. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    60
    Hello!
    There seems some issue in the compatibility with Unity 2022.2 new urp 14 on DX12.
    First load some scene with the pp volume. Unload the scene. Turning on/off hbao render feature, then load a scene with pp volume again will cause a crash.
     
  25. Issol

    Issol

    Joined:
    Mar 31, 2019
    Posts:
    4
  26. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Your decal shader is acting as opaque. If you want the outline around the circle (cutout) then the shader needs to implement proper shadowcaster pass (so that only opaque part is written to depth). If you don't want outline then have your decal shader to run on transparent queue.
     
  27. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    In the render object you should set Depth to "Write Depth". However Render Objects + Custom renderer feature has problems. Issue is on Unity side where the CopyDepth pass is not done properly: https://issuetracker.unity3d.com/is...nderer-feature-is-requiring-depth-and-normals
     
    Issol likes this.
  28. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Tried to reproduce but no luck... Happens only with DX12?
     
  29. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    60
    Yes, only with DX12. DX11 is OK with the same project.
     
  30. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    60
    Please try it in a build.
     
  31. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    First I'd like to know what you are trying to do. You are turning off hbao renderer feature (how?) but loading a scene that contains HBAO PP volume component? Can you clarify please, because turning hbao intensity to 0 will skip rendering it.
    How are you loading scenes? additively or not?
     
  32. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    60
    My game is level based. The pp volume is separately stored in the scene. The turning on/off operation is done by firstly set in the option menu, this step will disable the render feature. Then going to the "story mode" scene, there's no volume but the script will enable/disable the render feature in the date asset according to the configuration. After that When the level is loaded, the configuration will be checked to determine enable or disable the volume component(the HBAO component ,not the volume itself) in the scene.
    The crash will happen by following steps:
    1.main menu->(single mode) story mode
    2.load Level with volume and component(additive)
    3.quit Level ->(single mode) main menu
    4.Toggle render feature
    5.main menu->(single mode) story mode
    The crash will happen at the last step when re-entre the story mode scene.
    I use this way cause I thought only to diasbable completely might reduce the performance load. Is that ok if I just leave the feature alone and only set the intensity of HBAO to 0 to get a lossless performance?
     
  33. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    You can check by yourself with profiler, on both CPU and GPU (search for "HBAO" in profiler hierarchy). If you have no PP volume in a scene, or no HBAO to a volume, or HBAO intensity at 0 then there's no cost at all. By disabling the renderer feature you are not saving (I mean compared to the disable method I mentioned) a single render texture. Just one material, HBAO material that is 4KB in memory.
     
  34. jacknero

    jacknero

    Joined:
    Aug 15, 2018
    Posts:
    60
    I've changed to the toggle method that only disable the volume component and leave the render feature alone, the crash doesn't happen any more. Thanks!
     
    jimmikaelkael likes this.
  35. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    We just upgraded out project from 2021.3 to 2022.2.15 and as soon as we enable the HBAO render feature in the render data asset, the scene view tab/header flickers and sometimes stay black. Unless we either turn of scene view post processing, or make sure we dont have the game tab open at the same time as the scene view. Any idea whats going on. Our VFX artist really wants/need scene view postprocessing.
     
  36. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I cannot reproduce...
    If you are using LitAO mode, make sure that you set rendering path under HBAO settings correctly otherwise it can flicker.
     
  37. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    I dont event have a Volume/Volume profile in the test scene. Its just a empty scene with a camera and directional light. As soon as the mouse enters the scene view it flickers during mouse movement. If I select the camera the tool bar goes completely black upload_2023-4-18_12-4-20.png

    And it only happens if the PostProcess option is checked here, and both the Scene view and Game view are visible at the same time.
    upload_2023-4-18_12-5-48.png

    Forgot to mention, we're running URP 14.0.7 and not the built in pipeline
     
    Last edited: Apr 18, 2023
  38. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Still cannot reproduce. Which graphics API, DX11?
    That's all strange because if there's no volume in the scene then HBAO is not being executed.

    Try disable HBAO renderer feature and add this one I attached, which does nothing. Let's see if still happens.

    EDIT: sure I guessed it was URP when you talked about renderer feature. Tried with 2022.2.15 and URP 14.0.7
     

    Attached Files:

  39. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    Sure enough, adding only the dummy render feature causes the flickering. However, if I uncheck the "needs normals" the flickering stops

    We're using DX11 and deferred rendering. Just noticed that if I try with forward or forward+ the flickering also stops
     
    Last edited: Apr 18, 2023
  40. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    So it's clearly a bug in URP.

    I advise you to duplicate your project, clean it from all resources, keeping your project settings and URP settings. Add this dummy renderer feature and file a bug to Unity.

    We already have an issue filed for renderer feature bug (https://issuetracker.unity3d.com/is...nderer-feature-is-requiring-depth-and-normals) but yours is different.
     
  41. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    Voted on the linked issue. I also submitted a issue using your dummy renderer feature. The issue is there with a blank new project, the dummy renderer feature and deferred rendering.
     
  42. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Great! Now expect some weeks before they review and try to reproduce, and if they can reproduce they will file in issue tracker and give you the link. Don't hesitate to post it here for reference once you get it.

    Can you please send the blank project so that I try to reproduce? here or by PM is fine.
     
  43. Issol

    Issol

    Joined:
    Mar 31, 2019
    Posts:
    4
    Me voted too. Hope it will be fix in 2021LTS.
     
  44. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    Sure, heres the zip containing the basic project
     

    Attached Files:

    jimmikaelkael likes this.
  45. CRG-Hans

    CRG-Hans

    Joined:
    May 9, 2022
    Posts:
    11
    Issue confirmed and up for voting. https://issuetracker.unity3d.com/is...nd-a-renderer-feature-that-uses-normal-inputs
     
    jimmikaelkael likes this.
  46. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    103
    MSAA in HDRP causes HBAO to break. MSAA is kind of necessary since I'm making a VR game, other AA looks too icky. Asset is great, love it, but this is unfortunately a blocker for us.

    Or to be more accurate, I should say that when enabling MSAA, HBAO becomes the only thing visible.
     
    Last edited: Apr 22, 2023
  47. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    It's a bug in HDRP (https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-23#post-8846308) that has been fixed in 2022.2
     
  48. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    103
    Uh oh. I'm already using 2022.2.14. Did they regress?

    I'll try to update to 2022.2.16 and cross my fingers.

    Yeah, still broken. Just says:

    "A multisampled texture being bound to a non-multisampled sampler. Disabling in order to avoid undefined behavior. Please use Texture2DMS in the shader.
    UnityEngine.GUIUtility:processEvent (int,intptr,bool&)"

    Guess Unity broke it again if they fixed it before.
     
    Last edited: Apr 25, 2023
  49. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I was trying in 2022.2.0f1, but not in VR...

    Could you try with the dummy post process included in this post: https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-23#post-8846308
    - you remove HBAO from your volume and from custom post processes order
    - you add the DummyPP to same custom post processes order HBAO was
    - you add DummyPP to your volume and raise intensity

    Screen should become gray, and console spammed with the error you mentioned.

    If it reproduces with version above 2022.2.0 then yes they regressed.
     
  50. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    103
    Yep, it did exactly as you said with the DummyPP instead of the HBAO. Screen gray, same error spammed. Looks like a regression.

    Any way we can get Unity's attention about re-fixing this? I am but one small man. lol