Horizon Based Ambient Occlusion - HBAO image effect

I like very much the idea of a web player demo, however I’ve been told that with this kind of asset it’s quite easy to rip them off the demo in 5 minutes…

That´s new to me.
(The source of that information would be interesting…)

What about a WebGL-Demo or a downloadable Executable then?

By the way:
What is different in your allgorithm to the SSAO pro / SESSAO ones and where does the name “Horizon Based…” come from?

Yeah I learned this just a few days ago, after a guy new to the forums and with a hacker’s style pseudo asked me for a web player demo (just a few posts above). I suspected something strange, then doing a quick search on the forums:
http://forum.unity3d.com/threads/a-warning-to-those-who-develop-with-the-web-player.127405/

I will not enter into details, but basically if you host the demo somewhere it’s easy for them to get the unity package. From there they use a tool available on github to extract all build files from the package, then they use .NET Reflector to export the sources.

The final step is to recreate the project in Unity with the desired structure, re-create the scripts and
paste the code exported by .NET Reflector and finally import asset files.

For an asset like post processing image effect which just involves scripts and shaders I think it’s a matter of a few minutes…

I’ll check if it have obvious flaws :wink:

I can’t tell which algorithm SSAO Pro or SESSAO are using. However I’m almost sure they don’t use this approach, I’m not saying mine is better but since the algorithm is different you can expect different results.

“Horizon Based Ambient Occlusion” is simply another form of SSAO but has been called HBAO. As the name implies it’s horizon based approach, and it was explained in a few papers and examples from nvidia. The authors of the first whitepaper are Louis Bavoil, Miguel Sainz and Rouslan Dimitrov.

Basically this is approximating AO by determining the angle of free horizon around the hemisphere aligned with the tangent plane of the point being looked at, this involves a bit of raymarching the depth buffer. This is why it can be quite expensive depending on the settings and why I’m trying to balance performances with advanced techniques like interleaved sampling and separable AO kernel for the 1.3 update.

Look at this interesting document with nice pictures to illustrate it, paragraph named 2.1: Horizon-based AO with Ray Marching
http://frederikaalund.com/a-comparative-study-of-screen-space-ambient-occlusion-methods/

There’s another approach derived from and used in UE4 engine (explained in the document above) which I’ll may include in later update.

2 Likes

Thanks a lot!
Concerning the Webplayer thats horrible news! Any statement from Unity-guys?

Sincerely, I doubt Unity can do anything against that… Reverse engineering always existed.
As soon as you distribute some executables it can be ripped off.

On another note: 1.2 update is alive

Changelog:

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

Sadly, Texture arrays feature (and more generally Unity 5.4) has been delayed… We need to wait June 2016. :frowning:

Well, 1.3 update will be submittted for review on this week-end.

The goodies:

  • Improved performances (now on par with SSAO Pro but with better quality)
  • Improved compatibility (now compiles on every platforms, targetting shader model 3.0)
  • Improved settings (there are less settings, but they are more user-friendly)

For 1.4 update, I’m planning optional integration into Unity rendering pipeline: this will allow to only affect ambient lighting which will give even more realistic results.

Texture deinterleaving has been delayed until Unity allow to use it properly with RenderTexture arrays, but once functionnal we should get even more performances.

That sounds awesome. Thank you soooo much.

1 Like

1.3 is now pending review.

Here’s a screenshot:

Performances comparison with SSAO Pro on low settings:

Performances comparison with SSAO Pro in ultra settings:

1.3 update is alive :slight_smile:

1 Like

@jimmikaelkael I tried out the new version, looks fantastic great work :wink:

1 Like

Thank you mate! :slight_smile:

I’m already preparing 1.3.1 with improved color bleeding performances as it’s currently a bit slow. Should pop in the next week.

1 Like

1.3.1 update has been submitted for review.

Changelog:

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

Hey, I love this - is there a possibility of separating out just the color bleeding effect from everything else? The reason I ask is that when tweaked properly, it’s absolutely wonderful at casting light from emissive surfaces into the scene. I’d really love to use this package on a project I’m working on (I have already bought it) but unfortunately, whenever I walk up to a wall, the frame rate plummets. Is there any chance that’s a easily fixable bug?
Thanks!

If you set the Intensity of the effect to 0 but leave your color bleed saturation you’ll only get color bleeding.

I see, this is a known limitation with every SSAO solution: as the objects are closer from the camera the radius increases and the calculation is heavier.
I’ll try to see if I can limit this radius to prevent it going throught the roof.

EDIT: Forgot to add that 1.3.1 will certainly increase your performances with color bleeding.
I’ll be glad to send it to you before it’s approved if you PM me your invoice number :slight_smile:

Cool. When the intensity is 0, does the AO still calculate in the shader/script? Or is it truly disabled?
Also, allowing separate scaling of the bleed and AO effects would be good - right now they’re tied 1-1 but in my games case, I want a large AO width, but a small Bleed/Lighting cast, to help cut down on the graininess. Also, I hacked in on my end a separated system for the Bleed Saturation and Intensity…Saturation alone wasn’t cutting it. :smile: I love the asset, and I’d really like to be able to use it in game. If we can address the close up performance, (Possibly user-tweakable?), then I think we might be able to.
One final question - Is it possible to have an option to hook into the Unity Cinematic Image Effects package - in that it reuses the passes that that system are already generating? If so, that’d be a lot faster for anyone using that effects stack.
Thanks!

No in this case it’s not really disabled, but what is heavier is not calculating the AO term but collecting the surrounding samples. Color bleeding will anyway need those samples so there’s very little to no benefit (in term of performances) to truly disable AO calculation.

This is possible yeah, but in this case it will eat more performances. I’ve made the deliberate choice that color bleeding reuse samples used by AO to prevent the need for more sampling.

This is something I can add as a optional feature in a future version, why not.

I’m currently refining the rendering pipeline integration for 1.4 (will be a separate script called “HBAO_Deferred”, I’ll explain it in another following post), but once this is ready I’ll look into this issue :wink:

That will be really hard to get a benefit from this. To be really beneficial we would need to avoid sampling again and this means doing a lot of work in the same shader pass, in the case of AO what can be reused is depth and normal samples however you can’t guarantee that another effect will need the same sampling pattern…

It’s not impossible, but to be really efficient it would be better that I develop a full effect stack myself (and I have to admit I’m already putting all my efforts on improving HBAO first :)).

Well @Howard-Day has been extremely helpful to solve some problems and improve overall things.
Thank you Howard!

I’m still waiting for 1.3.1 approval, but 1.3.2 will get the following changelog:

  • 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 Like

“HBAO Shader is not supported on this platform”

What the heck?

Shader error in ‘Hidden/HBAO’: failed to open source file: ‘HBAO_MediumQuality.cginc’ at line 101 (on d3d11)

Compiling Vertex program with COLOR_BLEEDING_OFF RECONSTRUCT_EYESPACE_FACE_NORMALS_ON
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_TEXTURE_ALPHASPLIT_ALLOWED

DX11 Linear Deferred Unity 5.3.3

Have you recently updated the asset ?

It fails to find an include file so most likely you need to delete the “Horizon Based Ambient Occlusion” folder completely then reimport the package. To do this it’s better to first open a new scene.

You’ll may need to readjust the quality in the HBAO component after that.

Let me know.