Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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:
    780
    No worries, everyone is treated equally when reporting bugs.

    The best solution is to reproduce the issue in a blank project with just the DummyPP and start report a bug process from the menu. You will get a personal thread with the reviewer and if they reproduce on their side they will file it to the public issuetracker and give you the link.
    You can mention it is a regression since it is fine in 2022.2.0f1.

    Once you get this issue tracker link you can post post it here.
     
  2. Captain_Flaush

    Captain_Flaush

    Joined:
    Apr 20, 2017
    Posts:
    63
    Hello,

    HBAO works great, with great performance and it does not crashes like the standard SSAO on some mobile devices.
    So congrats for your work.
    I have the following question:
    - I am trying to enable/disable SSAO
    To do this I need to
    - disable the render feature
    - disable the depth texture
    - disable the posprocessing stack HBAO

    If I start the game with everything disabled and enable them once the menu is loaded (as I don't need any SSAO for loadings and for some devices at all), it crashes with:
    NullReferenceException: Object reference not set to an instance of an object
    HorizonBasedAmbientOcclusion.Universal.HBAORendererFeature.AddRenderPasses (UnityEngine.Rendering.Universal.ScriptableRenderer renderer, UnityEngine.Rendering.Universal.RenderingData& renderingData) (at Assets/Horizon Based Ambient Occlusion/SRP/URP/Runtime/HBAORendererFeature.cs:1003)

    It looks like an initialization issue. Could you please advice how to fix this?
    If the SSAO render feature is on when the game starts and I disable it afterwards, it works. However I have some devices on witch SSAO drops the FPS to 4. So I would leave everything off by default, and enable later on.

    Thanks a lot!
     
  3. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    You are using the wrong way to disable HBAO... There's much more easier, see below.

    Please take a look at this post first: https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-23#post-8946384

    For you, the best solution is to simply change HBAO intensity to 0. You can leave depth texture disabled all the time, as HBAO requests it per frame (if active).

    Below is a code example how to get reference to HBAO component and enable/disable it or set intensity:
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Rendering;
    4. using HorizonBasedAmbientOcclusion.Universal;
    5.  
    6. public class NewBehaviourScript : MonoBehaviour
    7. {
    8.     public VolumeProfile postProcessProfile;
    9.  
    10.     void Start()
    11.     {
    12.         HBAO hbao;
    13.         postProcessProfile.TryGet(out hbao);
    14.         if (hbao != null)
    15.         {
    16.             hbao.EnableHBAO(enabled);
    17.             hbao.SetAoIntensity(4);
    18.             hbao.SetAoRadius(2);
    19.         }
    20.     }
    21. }
    22.  
    Be careful to add the proper using directive to have correct access to HBAO component (Universal one).
     
  4. bearcoree

    bearcoree

    Joined:
    Mar 8, 2016
    Posts:
    72
    Is there a fix for rendering hbao behind the volumetric fog by now?
     
    pwka and Walter_Hulsebos like this.
  5. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    94
    Unfortunately over a month later, Unity 2022.3.0 is now LTS, and still the issue persists with MSAA + HBAO breaking. :(

    Is there ANY sort of workaround I can do on my end to the HBAO shader itself perhaps?

    Here's the exact error that occurs, if it helps:

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


    This is regarding the same issue I posted about earlier, with enabling MSAA and HBAO at the same time causing an AO-only view. Had tried reporting the issue to Unity, but thus far it has not been fixed or acknowledged.
     
  6. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    Nope, no fix yet, I'm sorry...

    You cannot fix from HBAO, the issue is in render pipeline code and that's what the DummyPP component test is intended to show...
    When you report bug, they always take care about it but it can take some time. They will always come back to you. They did not yet? How have you reported?
     
  7. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    94
    I reported it through the Unity Bug Reporter. This isn't really new though, I've been using Unity for over a decade (since Unity 3 or 4) and I don't recall ever receiving any kind of correspondence (or any action taken) on anything I've reported. So, the proper channels don't work which means I'm not sure what else I can do.
     
    Last edited: Jun 11, 2023
  8. Sisay

    Sisay

    Joined:
    Dec 6, 2012
    Posts:
    56
    don,t work with unity 2023.1 urp
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    Tested with 2023.1.1f1, URP 15.0.6, works fine here. Please make sure you follow installation steps correctly for URP as this is different as in Builtin, this is detailed in documentation.
     
  10. Sisay

    Sisay

    Joined:
    Dec 6, 2012
    Posts:
    56
    Hbao On defered mode kill all my lighting
    upload_2023-6-26_19-11-34.png

    hbao off
    upload_2023-6-26_19-11-11.png

    shadergraph shaders ignore hbao, urp_lit responds
     
    Last edited: Jun 26, 2023
  11. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    I cannot reproduce, please setup a repro project from scratch and send it to me.
    If shadergraph material is set to Lit, it works in HBAO Lit mode. Unlit shadergraphs won't show AO with HBAO Lit mode, this is expected.
     
  12. pwka

    pwka

    Joined:
    Sep 19, 2012
    Posts:
    49
    I bought this asset, but this unfortunately makes this package unusable to me. Do You have any plans for that?
     
  13. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    No plan for that as this is a limitation (missing proper injection point) into the HD pipeline. Unity is aware about it since years, but they don't care it seems...
    You can always ask a refund if you are unsatisfied.
     
    pwka likes this.
  14. pwka

    pwka

    Joined:
    Sep 19, 2012
    Posts:
    49
    Nah, apart from that, you did a great job! Maybe in another project I will find a use for it ;) Thanks for the clarification. Cheers!
     
  15. Leslie-Young

    Leslie-Young

    Joined:
    Dec 24, 2008
    Posts:
    1,146
    Guess I'm doing something stupid but AO is not working in stand-alone builds of my game. It works fine in editor. URP, Unity 2022.3.1. What might I be missing?
     
  16. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    You are not stupid, it's shader stripping issue in build.
    As with HDRP unity does like if no one will ever code it's own SSAO solution or use a 3rd party one... A bit tired to wait after them...
    That said, there's a simple workaround, please take a look at this post:
    https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-22#post-8333814
     
    Leslie-Young likes this.
  17. Skokon

    Skokon

    Joined:
    Jul 23, 2017
    Posts:
    74
    Hi, I'm on unity 2023.2.0a19, and its not working :(
     
  18. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    Just pushed a new version for compatibility with 2023.2.
    I'm sorry for the inconvenience... Please update to the latest HBAO version and it will work.
     
    Skokon and DragonmoN like this.
  19. Cloudwalker_

    Cloudwalker_

    Joined:
    Jan 3, 2014
    Posts:
    129
    What's the advantage of using this vs stock SSAO from Urp?
     
  20. wahntin

    wahntin

    Joined:
    Sep 17, 2019
    Posts:
    83
    Thanks a lot! I was running into the same issue after updating form 2021.3 to 2022.3.
     
    jimmikaelkael likes this.
  21. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    752
    I did ask about this in the dev blitz but I never got a response :(

    Question - Has the stripping issue of "directAO" and "indirect AO" been fixed yet? - Unity Forum
     
    jimmikaelkael likes this.
  22. Julio_Ibanez

    Julio_Ibanez

    Joined:
    Feb 11, 2022
    Posts:
    3
    Hi Mate,
    Great asset, it looks great on editor and runtime, 5 stars!

    …but it is not visible on my build .exe for windows.
    Unity 2021.3.3 URP

    HBAO assets are at the top of the render pipeline and post processing volume.
    Could it be because I am using Beautify 3? (I have disabled strip unused shader variants)

    Hope you have a magic tip to fix this?

    Cheers!
     
  23. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    The workaround is available in this post:
    https://forum.unity.com/threads/hor...hbao-image-effect.387374/page-22#post-8333814
     
  24. kaliyo

    kaliyo

    Joined:
    Dec 8, 2015
    Posts:
    5
    The plugin sadly doesn't work in exported builds using the newest 2022 LTS and URP version.
    The workaround doesn't work.
     
  25. CasualDutchman

    CasualDutchman

    Joined:
    Jan 20, 2016
    Posts:
    36
    Unfortunately, HBAO doesn't seem to be working in builds, not for our current project but also not in a brand new one.

    Unity 2022.3.7f1
    URP 14.0.8
    HBAO 3.5.2

    The workaround of sneaking Unity's own SSAO into a build does not seem to work.

    The strange thing is though ... It is rendering in the build, just not on top of the final image.
    The frame debugger shows HBAO working. The result is just not present.

    upload_2023-8-30_12-15-35.png upload_2023-8-30_12-15-41.png

    If you want more information, please ask. I am always willing to help out with info.
    And yes, even without the 3rd party assets 'RadiantGI', 'SCPE Sun Shafts' and other post processing, HBAO is not included in the final composite.

    The strange thing is though, I've made a completely new project, imported HBAO, made the SSAO workaround and it worked in build. After which I started to add more and more of the render features/Post processing effects that we are using and it still works.
    It is also working with Addressables, that package also tends to strip away unused thigns.
    It just doesn't work for our initial project, eventhough it is working in the Frame Debugger
    upload_2023-8-30_12-15-47.png
     
    Last edited: Aug 31, 2023
  26. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    780
    I tried a build with this Unity/URP version and the SSAO renderer data workaround and it works just fine.
    The HBAO pass is always there, that's not whar you should look at. When Unity does shader stripping it strips SSAO support from Universal shaders.
    Take a look at opaque material draw pass:
    Capture d’écran 2023-09-01 105501.png

    You can see that Lit shader has _SCREEN_SPACE_OCCLUSION keyword and that it uses _SSAOTex output from HBAO as _ScreenSpaceOcclusionTexture.

    When SSAO support is stripped you don't have this:
    Capture d’écran 2023-09-01 105726.png

    Maybe make sure that you are not overriding pipeline asset in quality settings. Check too if the camera is using the renderer you are intending to use.
     
    Last edited: Sep 1, 2023
  27. CasualDutchman

    CasualDutchman

    Joined:
    Jan 20, 2016
    Posts:
    36
    Thanks for the reply!

    For some reason, our first few builds with the workaround did not show HBAO but now they do.

    I assume some cached shader or Addressables object was preventing SSAO to be in the build.
    It is now, so that's great! HBAO adds to much to the look of the game :D
     
    Last edited: Sep 6, 2023
  28. CasualDutchman

    CasualDutchman

    Joined:
    Jan 20, 2016
    Posts:
    36
    Nevermind. It only worked because we completely turned off shader stripping as a test. It still doesn't work on Unity's own URP Lit shader.
    For some reason it does work on The Vegetation Engine shaders, but those always contain the keyword I guess