Search Unity

Horizon Based Ambient Occlusion - HBAO image effect

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

  1. iceb_

    iceb_

    Joined:
    Nov 10, 2015
    Posts:
    95
    With further testing, I noticed that with Temporal Filter Enabled, it's causing lots of ghosting effect. I also use URP TAA asset, so I tested it with and without that asset on, and same ghosting results in HBAO. The ghosting effect is similar to what it looks like when I turn off anti-ghosting feature in URP TAA.
     
  2. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Yeap, I enabled temporal filtering so that code is ready but honestly all I see in _MotionVectorTexture generated by URP is plain black (you can check that with Frame Debugger). It doesn't seem to write objects motion to it, I can confirm however that HBAO is correctly reading motion vector textures generated by URP.
    It seems that the feature is not really ready to be requested by 3rd party, but I'm sure this is actually worked on by Unity.

    This thread is mentionning the issue:
    https://forum.unity.com/threads/urp-new-motion-vectors-not-renderering.1195255/
     
  3. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
  4. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Nope, I don't like this option :)
    I can confirm this is URP issue, the texture remains black. I'm actually requesting motion vectors as pass input and all I get is black texture. Please wait this feature to mature a bit.
     
    AlejMC likes this.
  5. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    I'm getting this as well (in URP 12)—if I have Opaque Texture on in my asset and HBAO on Lit AO, all non-transparent objects in my scene seem to be rendering black, and it seems like the frame buffer stops clearing. No errors thrown, though.

    edit: Oop, missed the last post. sounds good!
     
  6. Oniros88

    Oniros88

    Joined:
    Nov 15, 2014
    Posts:
    150
    Any news in being able to use this AO in HDRP at the same time as volumetric fog?
     
  7. Galalab_QC

    Galalab_QC

    Joined:
    Jun 1, 2017
    Posts:
    1
    Hello. When testing on mobile with the Vulkan API on URP, the GPU bottleneck is greater than with OpenGLES. Could you please explain why?
     

    Attached Files:

  8. StopLookAndGo

    StopLookAndGo

    Joined:
    May 11, 2018
    Posts:
    17
    Hi, HBAO isn't working in my project. I have imported the SRP package and tried the demo. I've also followed the instructions in the readme, in both cases it's not working.

    Also, the SRP demo has HBAO attached to the Post Processing Volume, but the Readme says it should be attached to the camera. The Docs also suggest adding it to the Post Processing Volume, but when I do, it also adds a camera component.

    Unity 2020.3.20f1
    URP 10.6.0
    HBAO 3.4.4
     
  9. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Nothing changed yet in HDRP to allow this, I'm sorry.

    No clues, I'll have to check that.

    Tested with these versions and everything works fine, but anyway you wrote me an email and I sent you a video showing how to setup.
     
  10. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    This is fixed in v3.4.5 (you'll need to unpack embedded URP package again after update).
     
    gewl likes this.
  11. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Was there a tutorial for making shader compatibility with LitAO?

    Amplify shaders templates are finally compatible giving proper depth normals but they're not compatible with LitAO.

    I need to know what needs to be added.
     
  12. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Vulcan on mobile is not good and I don't reccomend it personally. This is probably not the devs fault in my personal experience.
     
  13. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
  14. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
  15. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
  16. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Did you update HBAO to latest? It does work on both. Latest version should include fix for black screen when opaque texture is enabled.
     
  17. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    I'll double check. I'm pretty sure I updated just recently.
     
  18. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Also after update you need to unpack URP package again, not much convenient I have to admit...
     
  19. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Ok my bad turns out it was the opaque texture setting.

    By the way, it seems lit AO turns off color bleed, is that intentional? And if so is it temporary?
     
  20. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Newest HBAO version specifically fixed this so you can keep Opaque option enabled (if you need it). On older versions, you can of course also just turn that option off if you don't need it for anything.
     
  21. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Yes it's intentional, when injecting into pipeline, it expects an AO value and nothing else. I could put colors into screen space occlusion texture but when applying to materials it reads into a single channel anyway.

    That will never change, so I'll hide color bleeding setting when LitAO is enabled in future version.
     
  22. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    By the way, tonight I'm pushing another update to fix temporal filter ghosting (on URP12+). I was stupidly sampling ao history with point sampler, I'm sure I copied the line on motion vectors sampling, shhh laziness.
     
  23. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Is something missing for me? When i enable temporal the SSAO effect just vanishes on the game view, and once i got a stack overflow error.
     
  24. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I did not had this exact same issue specifically but in the current version temporal filtering has problems with multiple cameras (on URP of course). And viewing scene and game view at the same time sort of account for multiple cameras so I'm not surprised. I noticed in this case the history buffers get released/reallocated every frame (so there's no longer any ao accumulation) but the texture count in profiler does increase despite I'm calling RenderTexture.Release() explicitely.
    I've rewritten history buffers system to use the new RTHandles system instead of RenderTexture for those persistent buffers and I made sure to hold these per camera which fixes the issue.

    Not sure when I'll push the changes because I need to check the code on older URP versions as RTHandles did not existed so I'll need to use appropriate defines in code. Might be on next week.
     
    iceb_ likes this.
  25. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    867
    Hi, does it work in HDRP VR ?
     
  26. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    I guess its a known issue on 2021.2

    Assets\Horizon Based Ambient Occlusion\SRP\HDRP\Editor\HBAOEditor.cs(35,30): error CS0115: 'HBAOEditor.hasAdvancedMode': no suitable method found to override
     
  27. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    It has been fixed some time ago in URP but not in HDRP, I'm sorry for the inconvenience, this will be fixed in next release.
    In the meantime you can rename the field to hasAdditionalProperties.
     
  28. Rastapastor

    Rastapastor

    Joined:
    Jan 12, 2013
    Posts:
    589
    Easy i fixed it myself, just wanted to report. :)

    Btw great asset, bumps up quality of scene sagnificantly :)
     
  29. Coke2016

    Coke2016

    Joined:
    Aug 14, 2017
    Posts:
    1
    is there a tutorial ?
    xx.png
     
  30. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    1st warning: as stated in warning text, to enable HBAO you need to override intensity setting. Check the intensity checkbox and HBAO will enable, provided you had properly setup HBAO for URP with the help of documentation.

    2nd warning: URP introduced motion vectors in version 12.0 -> Unity 2021.2.
     
  31. Roggi_

    Roggi_

    Joined:
    May 14, 2014
    Posts:
    84
    Hi jimmikaelkael,
    I've just tried your asset in our game and it's just an amazing visual improvement for us, but we've run into a problem where combining this with DLSS causes a weird cropped in frame.

    When both HBAO and DLSS is enabled, the frame is cropped in (to what I assume is the resolution that DLSS uses).
    Disabling either HBAO or DLSS fixes the issue. Surprisingly, it works just fine with AMD FSR.

    Iam not sure what's going on, could you please look into this issue?

    We are using Unity 2021.2.4f1 with HDRP 12.1.1.

    This is how we set the Dynamic Ress mode and render scale. Same for both FSR which works with HBAO and DLSS which doesn't.
    upload_2021-12-22_11-0-27.png
     
  32. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Hi, yes it seems that DLSS currently has limitations with custom post processes.
    Unity added a new API to customize the rtHandleProperties of a particular RTHandle in 2022.1.0b2:
    Capture.PNG I will wait this new API get out of beta then I will do the required changes in HBAO, I'm sorry for the issue.

    EDIT: It seems that I will not have any change to do, HBAO + DLSS should work fine in 2022.1.0b2
     
    Last edited: Dec 22, 2021
  33. len4ikuz

    len4ikuz

    Joined:
    Dec 29, 2020
    Posts:
    1
    Hi there!
    Visual quality of asset is amazing but i find out some big performance issues. After i add HBAO to my scene, FPS drops from 250 to 150. I think i'm doing something wrong, but i have no idea what exactly. I'm using Unity 2020.3.14f1/URP 10.3.2
    Profiler.png Settings.png
    ON-OFF.jpg
     
  34. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    What can affect performances a lot is AO quality, ao resolution and ao radius, LitAO mode has a bit lower cost than normal mode and is more realistic.
    Also temporal filtering is the key to good ao quality at low cost, so I'd suggest you to use at least URP 12.

    Here's an example of settings:
    Capture.PNG
    Capture2.PNG

    With this you should be able to divide the HBAO cost by 4.
     
  35. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    Hi,

    Does it work on Nintendo Switch and console in general?
    We just did a quick test and it doesn't seems to work on Switch (it render correclty in editor).
    We're on Unity 2021.2 and URP12.

    Thanks!
     
  36. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I can't test it, but it should be working.

    What's the graphics API being used?
    Are you using LitAO or Normal mode? (in this case it could be due to shader stripping)
    Any error in the log saying HBAO shader is not supported in the platform? (shader fails to compile)
     
  37. Qleenie

    Qleenie

    Joined:
    Jan 27, 2019
    Posts:
    867
    Still interested in above question ;)
     
  38. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    Hi,

    Nintendo uses NVM, a proprietary API by nVidia on Switch.
    Sadly after a couple of tests the effect messes up the rendering badly on Switch: we're using distance shadowmask and it seems that all the baked lighting informations get thrown out when HBAO is active and lighting is messed up on dynamic and skinned mesh too. Just reverted to URP SSAO and everything is back to normal.
    It works ok in editor and on a PC build.

    I tested it on a very complex project, I can try in a simpler one and give more informations.
     
  39. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    Thanks for feedback, yeah testing the demo scene in simple project might help.
     
  40. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    I've found an issue with Camera stacking and transparent objects being rendered infront of opaque objects.

    Using Unity 2020.1.13f1
    And the latest HBAO version.

    The base camera renders all but 1 custom layer. And the overlay camera renders only the custom layer.
    (For context, certain 3D edit tools need to render infront of everything else)

    When the overlay camera is in the Stack list in the base camera the transparent cube (just a basic transparent lit shader) is rendered infront of the dragon whilst its placed behind.

    Removing either the overlay camera from the stack, or telling the overlay camera to also render the default layer makes it behave correctly again. Also turning off HBAO fixes it ofcourse, but thats no option :)

    Any ideas on how to fix it? Besides removing the overlay camera from the stack, which would seem the current optimal solution.
     

    Attached Files:

  41. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I have to admit that I'm a bit confused by the fact you intend to use overlay camera to render infront and point issue when cube is rendering infront ^^
    I guess cube is not part of custom layer rigth?
     
  42. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Oh yeah the cube is just on the default layer, sorry for the confusion!

    In my case any transparent object is rendered infront when the stacking is applied. Before I added HBAO today it was all fine as it was ment to be.
     
  43. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I was able to reproduce in URP < 10.0, but not in URP >= 10.0. This is were they added ScriptableRenderPassInput enum.
    On versions below 10.0 you need to tick "Opaque Texture" either on pipeline asset or on the base camera.
     
  44. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Hmm I'm using URP 8.2.0 for the project. Also had the Opaque Texture ticked on in the pipeline asset. (And the base camera is using the pipeline settings) And it still happens.

    I just made a new project to check if it was some other asset perhaps, but on 2020.1.13f1 with the URP template, then imported HBAO, you'll get URP 8.2.0 and it also happens there. If you want I can zip up the example project for you to look at. Even if the overlay camera is set to "Culling" "Nothing" the issue happens.
     
  45. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    There's nothing I can do to fix this issue, Unity added OnCameraSetup override and ScriptableRenderPassInput in URP 10. I'm sorry for the inconvenience.
     
  46. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Alright thanks! Ill figure out another way to render the tools infront :)
     
  47. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Just out of interest, on which URP below 10 where you able to reproduce it?
     
  48. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    It was 7.3.1.
     
  49. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    upload_2022-1-7_14-55-21.png

    Lit AO appears to break if camera stacking is used. Normal mode is fine.
    upload_2022-1-7_14-56-40.png

    EDIT: Actually, this happens any time more than one camera is active.

    EDIT2:

    OK i discovered something weird, with my custom shader, loading an object from an adressable makes LitAO not work on that object. Normal AO works fine...

    This is very bizarre, can't tell where the error is.
     
    Last edited: Jan 8, 2022
  50. jimmikaelkael

    jimmikaelkael

    Joined:
    Apr 27, 2015
    Posts:
    796
    I think that the problem is that the _SCREEN_SPACE_OCCLUSION shader variant for your custom shader get stripped by addressable, because that keyword is enabled only at runtime.

    Please take at look at this thread, and more specifically this post:
    https://forum.unity.com/threads/addressable-and-shader-variants.1113805/#post-7208395