BGE HBAO Ambient Occlusion Shader

UPDATE - UPBGE only

Ok as promised, here is the update.

IMPORTANT:
To increase performance and quality on smooth curves, the shader uses the UPBGE render attachments to read the normals from.

Setup guide:

  1. Add an Attachment under “Render”-tab > “Attachments” (UPBGE v0.2.5+) and set up like this:
    setup_1

  2. For EACH MATERIAL in your scene, use material nodes and output the attachment like this:


    (you can also replace the normals from the Geometry node with the normals from a “Material” or “Normal Map” node to include textured normals)

  3. Add the HBAO shader
    hbao.glsl (8.2 KB)

  4. Configure shader variables under “THIS NEEDS TO MATCH YOUR CAMERA SETTINGS” and “USER VARIABLES”

  5. Enjoy

Results:

AO Only:

Shaded scene:

Changelog:

  • Implemented dedicated normal pass through UPBGE Attachments
  • Improved noise influence to break up the before clearly visible sampling ray directions
  • The geometry distance now influences the AO radius, so the AO effect doesn’t “scale up” when you move away / “scale down” when you move closer
  • Fixed bug where the “sampleSteps” variable wasn’t used correctly
  • Slight performance increase

Todo:

  • Fix on AMD (I only have an Nvidia card)

Note:

Because this came up many times:

The HBAO algorithm is VERY performance hungry, this is something I cannot change. So don’t expect your inbuild/old graphics card to run this!

Even current AAA games only use HBAO if you are on HIGH settings!

Anyways, hope this update will help you.

8 Likes