Horizon Based Ambient Occlusion - HBAO image effect


Preview on the Asset Store

:heavy_check_mark: Supports Unity 6
:heavy_check_mark: Supports Unity 2023.x
:heavy_check_mark: Supports Unity 2022.x
:heavy_check_mark: Supports Unity 2021.x
:heavy_check_mark: Supports Unity 2020.3+
:heavy_check_mark: Supports URP and HDRP 10.3.2+
:heavy_check_mark: Supports orthographic cameras
:heavy_check_mark: Supports VR
Horizon Based Ambient Occlusion (HBAO) is a post processing image effect to use in order to add realism to your scenes. It helps accentuating small surface details and reproduce light attenuation due to occlusion.

HBAO delivers more accurate AO compared to the other SSAO solutions available on the asset store, and this without any compromise on performances.
This algorithm is highly optimized to use minimal GPU time and offers the best quality to performance ratio. Asset contains color bleeding and temporal filtering features. Gaia extension ready.

Compatibility:
• Standard render pipeline, forward and deferred
• Universal Render Pipeline 10.3.2+
• High Definition Render Pipeline 10.3.2+

The effect is scalable in order to achieve the proper performances. Source code included in the package.

HBAO settings:

Changelog

3.6:

  • Added RenderGraph support (URP)

3.5.5:

  • Fix for Unity 2023.3 (URP & HDRP, no RenderGraph support yet)

3.5.4:

  • Fixed broken LitAO (URP)

3.5.3:

  • Fixed right eye issue with Quest (Builtin)
  • Fixed editor warning (URP)

3.5.2:

  • Fixed compatibility with Unity 2023.2 (all pipelines)

3.5.1:

  • Fixed dynamic resolution artefacts (URP and Builtin)
  • Fixed blur uv delta incorrect in some cases
  • Fixed warnings

3.5:

  • Standard pipeline: added VR SPI support
  • Standard pipeline: fix compile error when built-in VR module is disabled
  • Reduced number of shader variants (all pipelines)
  • URP/HDRP: fixed VR SPI projection issue
  • HDRP: fixed issue with R16G16B16A16 and R32G32B32A32 buffer formats

3.4.12:

  • Standard pipeline: fixed composite bug with MSAA and transparent objects
  • HDRP: fix doubled properties in 2022.2

3.4.11:

  • Fixed bleeding occlusion on screen edges

3.4.10:

  • Fixed bug with orthographic projection

  • Reduced number of shader variants

  • URP: fixed wrong camera view normals on URP versions 10 and 11

3.4.9:

  • HDRP: fixed AO shifting issue

3.4.8:

  • HDRP: fixed VR SPI
  • URP: prevent color bleeding to be used along with LitAO mode
  • URP: warn about 2021.2+ required for motion vectors (temporal filter)

3.4.7:

  • Fixed temporal filter issues on URP (use BufferedRTHandleSystem)
  • Fixed obsolete hasAdvancedMode field on HDRP
  • Added min/max range for multibounce setting on HDRP

3.4.6:

  • Fixed temporal filtering ghosting issue on URP

3.4.5:

  • Added rendering path option in URP to fix issues with LitAO+Deferred
  • Fixed scene rendered black in URP12 with LitAO and opaque texture enabled

3.4.4:

  • Fixed temporal filtering issue when using camera normals on URP

3.4.3:

  • Fixed wrong camera view normals on URP

3.4.2:

  • Enable temporal filtering on URP (URP12+, Unity 2021.2+)

3.4.1:

  • Fixed Deinterleaving per frame GC allocation on URP

3.4:

  • Added LitAO on URP (requires URP 10.0.0 or newer)

3.3.4:

  • Fixed VR Single Pass on URP

3.3.3:

  • Fixed VR on Standard Render Pipeline

3.3.2:

  • Added support for URP 12.0.0

3.3.1:

  • Added support for upcoming URP 10.0.0 (support view normals)

3.3:

  • Added VR support to Standard Render Pipeline HBAO

3.2.1:

  • Added assembly definitions for editor scripts

3.2:

  • Fixed colorbleeding white color bleed beyond max distance
  • Switched HBAO for URP to Post Process VolumeComponent

3.1:

  • Added HDRP support
  • Added more settings helper methods
  • Added namespaces for each render pipelines variants
  • Use 16bit floating point texture format for noise when platform supports it
  • Fixed wrong albedoMultipier setter method

3.0:

  • Rewritten scripts/shaders code for Unity 2019.1+
  • Added scene view effect
  • Added temporal filtering
  • Added interleaved gradient and spatial distribution noises
  • Added possibility to stack AO components (both Standard and Universal Render Pipeline)
  • Added UI for Universal Render Pipeline AO setting assets
  • Fixed wrong RenderTextureFormat for color bleeding
  • Fixed memory leaks
  • Improved number of compiled shader variants

2.9:

  • Fixed URP version shader keywords problem resulting in blackscreen in builds
  • Fixed URP support on OpenGLES2 graphic API
  • Fixed PS4 compilation error
  • Fixed orthographic camera support on OpenGL, OpenGLES2 and OpenGLES3 graphic APIs
  • Fixed AO consistency on various resolutions (render scale, dynamic resolution)
  • Fixed incorrect view normals sampling at half resolution
  • Allowed use of local shader keywords instead of global keywords
  • Removed obsolete random noise, downsampled blur and quarter AO resolution

2.8:

  • Added URP support 7.1.8+ (Unity 2019.3+)

2.7.2:

  • Fixed deprecated editor API

2.7.1:

  • Fixed obsolete scripting API
  • Added view normals debug display

2.7:

  • Added multibounce approximation feature to replace older luminance influence setting
  • Improved AO intensity response
  • Improved blur
  • Fixed RGB colormask on composite passes

2.6:

  • Fixed emission not cancelling AO in deferred occlusion
  • Added color bleeding emissive masking
  • Fixed VR Single Pass support in Unity 2017.2

2.5:

  • Added offscreen samples contribution setting
  • Improved color bleeding performance

2.4:

  • Added support for Single Pass Stereo Rendering

2.3:

  • Fixed Camera.hdr obsolete warning in Unity 5.6
  • Fixed inconsistent line endings warning in HBAO.shader

2.2:

  • HBAO_Integrated: adjusted to avoid any per frame GC allocation

  • Increased Max Radius Pixels limits to be compliant with 4K resolution

  • Prefixed radius Slider control variable type with namespace to avoid potential ambiguity

2.1:

  • Fixed orthographic camera support with Deinterleaving in Unity 5.5+

2.0:

  • Added a rendering pipeline integrated HBAO component (HBAO_Integrated.cs)
  • Fixed orthographic camera support in Unity 5.5+

1.8:

  • Fixed bad rendering path detection in builds
  • Explicitely declared _NoiseTex as shader property

1.7:

  • Added downsampled blur setting
  • Added quarter resolution setting
  • Improved samples distribution (Mersenne Twister)
  • Fixed black line artifacts in half resolution AO using reconstructed normals
  • Fixed SV_Target semantics to the proper case
  • Fixed ambiguous lerp in HBAO fragment

1.6:

  • Added Reconstruct as a per pixel normals option
  • Simplified a few lerps in HBAO shader
  • Removed sliders for max distance and falloff distance so as to remove bounds

1.5:

  • Added deinterleaving which gives performances gain for large radiuses and HD/UltraHD resolutions
  • Fixed luminance influence not handled correctly in debug views

1.4.3:

  • Improved overall performances
  • Added support for orthographic camera projection

1.4.2:

  • Added per pixel normals setting (GBuffer or Camera)
  • Added Max Distance and Distance Falloff settings
  • Fixed AO step size, allowing to get more interesting contact occlusion
  • Moved initialization to OnEnable instead of Start
  • Avoid to modify GUI.Label style directly as to not mess up the stats window
  • Renamed “Show Type” setting to “Display Mode”

1.4.1:

  • Fixed editor error while applying a preset in play mode

1.4:

  • Added new user friendly UI & some presets
  • Fixed luminance influence not showing in AO only views
  • Fixed vanishing AO bug in while in editor

1.3.4:

  • Integrate with Gaia as an extension

1.3.3:

  • Added AO base color setting
  • Fixed leaked noise texture
  • Fixed demo scene

1.3.2:

  • Fixed bad rendering path detection in unity editor with camera on “Use Player Settings”
  • Limit the maximum radius in pixels to address the close-up objects performance issue
  • Added an albedo contribution and multiplier for the color bleeding feature in deferred shading
  • Increased intensity upper bound (useful for dark environment)

1.3.1:

  • Improved color bleeding performances
  • Fix NPE when adding the HBAO component to a camera for the 1st time

1.3:

  • Improved performances
  • Improved compatibility (compiles on every platforms, targetting shader model 3.0)
  • Improved settings (there are less settings, but they are more user-friendly)

1.2:

  • Added Color Beeding feature
  • Fixed artifacts on cutout materials in forward rendering

1.1:

  • Optimized blur (packed ao and depth into 1 texture to reduce the number of textures to fetch, and outer half of the kernel doing in-between sampling)
  • Fixed blur sharpness
  • Added another noise type
4 Likes

1.1 update is in pending review

Changelog:

  • Optimized blur (packed ao and depth into 1 texture to reduce the number of textures to fetch, and outer half of the kernel doing in-between sampling)
  • Fixed blur sharpness
  • Added another noise type

This looks very impressive! It looks like in your screenshots at the top, the performance cost for your HBAO as configured is actually less expensive than the Unity SSAO you configured while still being more accurate.

Have you compared your solution against SESSAO and SSAO Pro, by chance? I know those are more optimized SSAO implementations vs stock Unity, so I’d be interested in seeing the performance vs quality comparison against your HBAO with either of those assets.

Thank you!
It all depends how you set it up… As you can see on HBAO settings you can push up sample directions and steps: pushing these to the max will give very accurate AO but there’s a lot of chance you’re ruining your performances in this case.

But yeah, with proper settings, you get better AO than with Unity SSAO with slightly less perfs hit.

I do not own SESSAO so I can’t tell for this one, however I own SSAO Pro and I’d say it’s faster than HBAO although I didn’t have compared accuracy like I’ve done with Unity’s SSAO. I’ll try to post a screenshot of such comparison soon.

Great, thank you in advance! I have SSAO Pro as well. If your HBAO can be configured to achieve better results without too much of an additional performance hit, I’m definitely interested in including it as a graphics option for those who want that extra bit of polish vs SSAO. I’ve earmarked this asset for purchase when I have some spare dollars to throw at the asset store. :slight_smile:

First comparison, targetting low performance hit:


HBAO


SSAO Pro

Second comparison, targetting quality:


HBAO


SSAO Pro

In the second comparison, SSAO Pro is at max quality, HBAO can get even higher quality.
As you can see, It’s matter of choice of higher perfs vs higher quality.

1 Like

Thank you for the comparison shots! Very informative from my perspective.

Would you mind sharing what GPU you’re using to test? Thanks again.

I have a pretty good GPU: MSI GTX 760 twin frozr OC

1 Like

Can you please add a webdemo to see it in action? :slight_smile:

Color bleeding feature is planned for 1.2, which should be ready in a few days.


No AO


HBAO only


Color Bleeding only


HBAO with Color Bleeding

When set properly, performance is on par with Unity’s SSAO.

I’m sorry but I do not currently have a complex scene already available for this but I’ll try to provide one.

Does it work with SpeedTree in Forward? Both Unity and SSAO Pro give awful artifacts there.

Unfortunately no, there’s some sort of transparency… I will investigate this.

Do you know if SESSAO have the problem too ?

Pity, have to use deffered just for that. I don’t own SESAO, but I remember they discussed some solution to make it work about half a year ago.

And when I asked Speedtree guys, they said it is Unity problem, not their.

Well, after more tests, they work correctly with HBAO’s low quality mode. The reason is that this mode doesn’t use the camera normals texture.

From what I can see, it’s Unity bug, not SpeedTree… There’s a possible workaround which is to reconstruct normals from depth buffer.

I’ll let you know once I get the problem solved.

1 Like

I have the workaround ready, it will be included in 1.2 update which should be submitted for review tomorrow.

2540337--176464--ForwardAOonly.jpg 2540337--176465--ForwardAO.jpg

This workaround should solve artifacts with every cutout materials in forward rendering mode until Unity can get a fix for this.

1 Like

Wow, that’s incredible! My wallet is ready :slight_smile:

1.2 update has been submitted for review :).

Now, next update will focus on improving performances. We’ll be using 4x4 interleaving with separable AO which means better texture cache utilization.

From the papers I’ve read it should give a really good performance increase.

1 Like

I have 2x2 interleaving already in place and from editor’s profiler there’s already 1.5x performance increase without any compromise on the quality. And interleaving is even more efficient at higher resolutions :slight_smile:

Actually, I don’t use texture arrays to reinterleave the AO (as unity doesn’t support them below 5.4), so once Unity 5.4 is out I’ll use them and we’ll get even better cache utilization!

I have 4x4 interleaving almost ready too, but for this one I prefer to wait unity 5.4 as reinterleaving it may be overkill without texture arrays as in this case it works with 16 layers while 2x2 interleaving works with 4 layers.

Very interested but would like to see a webplayer with a white untextured scene and with these controls:

  • framerate
  • on/off
  • quality / radius sliders

Thanks!