How to selectively disable n8AO for specific objects?

Hi,

Im using n8AO for ambient occlusion and would like to exclude certain objects from receiving (or contributing to AO.)

What is the recommended approach to disable n8AO for specific meshes only?

Is there an official or preferred method (e.g., layers, render masks, pass filtering, etc.)

here’s a example screenshot, lets say i dont want AO for my water Mesh

Thanks!

From official n8AO docs, there are three known ways that should work.

  1. If the water mesh is transparent = true, you could set:
    n8aopass.configuration.transparencyAware = true;
    and it should work out of the box.
  2. If the water mesh is not transparent, you could force to not receive AO by keeping the previous line and setting:
    watermesh.userData.treatAsOpaque = false;
    and it should treat water mesh as transparent.
  3. If the water mesh is not transparent and you don’t want to be treated as transparent by n8AO, you could set:
    watermesh.userData.cannotReceiveAO = true;
    but keeo in mind this is not recommended as it has to be rendered twice and should have an impact on performance.
2 Likes

You can disable n8AO per mesh using the built in flags.

If your water material is transparent, just enable:

n8aopass.configuration.transparencyAware = !0;

That should handle it automatically and is the cleanest solution.

If your water is not actually transparent but you still want n8AO to ignore it, keep transparencyAware enabled and set:

waterMesh.userData.treatAsOpaque = !1;

That makes n8AO treat it like a transparent object without changing your material.

If you really want to force it to not receive AO at all, you can do:

waterMesh.userData.cannotReceiveAO = !0;

But that is not recommended because it renders the mesh twice and can hurt performance.

For a water mesh, the transparencyAware approach is usually the best option.