Horizon Based Ambient Occlusion - HBAO image effect

Update update - setting HBAPO ‘Mode’ to Normal instead of Lit AO allows the two to work together once again.

Update update update - distortion effects “overwrite” HBAO (objects behind a distortion shader do not render HBAO). Likely, I guess, because the shader grabs what’s behind them to re-render it distorted, and that doesn’t include HBAO (immediate edit - yes that’s the case, you can see in the shader’s preview that the screen doesnt have HBAO yet).

Still investigating.

Edit update - the scene color node in shader graph (subsequently likely the one that the default unlit shader uses) captures the scene color before it does HBAO’s post processing. You can change the render order of the shader, but it does not affect when it captrues what’s on the screen.

Still investigating.

Update update update update - I managed to sorta ‘solve’ this by hardcoding the renderPassEvent in HBAORendererFeature to BeforeRenderingPostProcessing, though anything from 500 to 599 works. The HBAO in this cases renders overtop of distortion effects as though they weren’t there, which I find kinda weird, but it makes sense I guess. I don’t know why it’s so hard for the HBAO to be drawn on my screen, then a shader to access that, but it seems that’s very difficult.

Unfortunately this does mean that effectively HBAO will render a clear outline overtop of distortion, but for something simple like heat distortion this isn’t a big issue.

– Edit to that. Hopefully final edit. Setting renderPassEvent to around 400 works. AfterRenderingSkybox is the one there but you can add or subtract with this value. HBAO renders, then distortion distorts it, including the scene color node in shader graph.

G’morning, was upgrading my HDRP project from 2022 LTS to unity 6 (.0.36f1) LTS, and noticed that hbao stopped working, it doesnt affect the image in any way anymore, even the debug options dont work.
I also noticed Unity changed quite a bit in the volume settings scheme, there isnt an enable/disable button for the “master effect” and the individual effects anymore. It looks like it broke the hbao inspector in more than one way.
Is that maybe a clue to why hbao doesnt work here? Any suggestions? Thank you

Edit: It seems like the “override state” buttons dont exist anymore, so I tried removing the logic in this “IsActive” bool line on HBAO.cs:

public bool IsActive() => intensity.overrideState && intensity.value > 0;
to
public bool IsActive() => intensity.value > 0;

And it worked

1 Like

Yes can confirm - it is a bit broken in Unity 6 (URP for me), this seems a fix for it not appearing. But there are UI issues too, the controls can get locked up until you select the default volume again. Overrides appear under Lighting not Post Processing for a scene volume?

Unity 6 is (a bit of) a car crash in how it changed all the post processes to be present though actually off if some intensity etc is 0?! This is apparently just echoing how it worked internally but it sure is problematic from a UI perspective not being able to just toggle an effect!
So Unity 6 means all custom post processes need a fix?

Thanks for report, I’ll take a look soon. That’s bad they changed this, without any prior deprecation warning… as usual with them.

Upgrading a project from 2022 to 6 I did not need the above code change. But that intensity.overrideState check is obviously seeing if you ticked the box to override the intensity from the default value, which seems like a big problem - choosing presets in HBAO will mean the intensity is not overridden but still needs to be read/valid. Tick the internsity box and the effect starts working
But looks like VolumeParameter class etc changed in SRP pipeline in 6, perhaps forced always true pre 6!!