Devlog #4: Apply Ambient Occlusion


Ambient Occlusion (AO) is a technique used to darken areas where light is naturally blocked by nearby geometry, helping create a stronger sense of depth and contact between objects. In practice, AO is often calculated by estimating how much of the surrounding hemisphere is visible from a given point on a surface.

There are two main types of AO algorithms:

  • Static AO – Precomputed during asset creation, where occlusion is baked directly into the geometry or textures.
  • Dynamic AO – Computed at runtime, usually based on changing or dynamic data.

Dynamic AO is commonly implemented with Screen-Space Ambient Occlusion (SSAO). This technique samples the depth buffer and uses the reconstructed geometry to estimate visibility for each pixel. The result is then applied as a shading factor across the screen.

However, in voxel-based or procedurally generated games, it’s often more efficient to calculate AO directly during voxel generation.

For reference, you can read a detailed breakdown of Minecraft-style AO here: 👉 0fps.net: Ambient Occlusion for Minecraft-like Worlds.

In my implementation, I simplified the method:

Instead of using 4 AO levels, I only use 3 (as shown in the picture).

For special case, if a vertex would normally have AO = 1, but there are voxels along its edges, I assign AO = 2.

🔹 Voxel AO Calculation

Each voxel requires checking up to 20 neighboring voxels to determine AO for all its vertices. For each face, specifically, you only need to check 8 neighboring voxels.

Leave a comment

Log in with itch.io to leave a comment.