Custom AO shows over the Volumetric Fog due to late injection in the RP

When using HDRP’s volumetric fog with a custom AO solution, the fog gets modulated by AO like in the attached image.

The reason is simple: The Volumetric Fog cannot be moved to execute sooner or later in the RP and the AO’s injection point in the RP is limited to 3 options (CustomPostProcessInjectionPoint): AfterOpaqueAndSky, BeforePostProcess and AfterPostProcessToo, all being after the fog is rendered.

Suggested solutions that are not satisfying:

  1. Reduce the max distance of AO: Only partial solution. On close geometry behind the fog, the undesired effects still shows at its worst, like in the attached image.
  2. Modify the HDRP so that the AO is rendered before the fog: Not trivial, duplicating and modifying the HDRP is no easy task, comes with lots of risks and sustained development effort. Also, community support is minimal on this.

@SebLagarde Is there a solution to this that I’m missing or is it a limitation I have to wait to be fixed? Thanks.

Hi Alex,

I have the same problem with my custom AO effect, did you already find a solution?

Unfortunatelly no. A workaround for this is to reduce the distance at which AO starts to fade out if your AO solution has such an option.

I use an HBAO solution from the Asset Store and it features a max distance setting, as well as a fading distance setting. Depending on how close (dense) the HDRP fog is, I lower that distance, so that where the depth is high (and fog is thick) I render no AO.

Of course, this is not a complete solution and there are some cases where AO still renders strongly over close thick fog.

One example is when you have a light (spot or point) and some close geometry behind the light’s lit fog. In such case the fog is more intense than usual (and that’s aesthetically intentional of course), but the scene depth is small (due to near geometry behind the close fog), so AO renders at full power over the bright close fog. As you can imagine, it looks horrible.

I’m quite sure Unity could quite easily allow for sooner injection points in the HDRP, so that we can render shadowing effects like AO before the fog.

Still waiting for a reply here from someone at Unity.

Thanks for the reply! I’m currently testing a workflow with the custom pass examples ( GitHub - alelievr/HDRP-Custom-Passes: A bunch of custom passes made for HDRP ) Looks like the Liquid gets rendered as a Screen Space Effect behind the fog, so it should work. I just have to adapt my code.

1 Like

I think that a “before post effects” custom full quad rendering with scene depth input/write on, as a transparent pass works, but I’m still testing…

Hi, after testing the transparent approach, I recognized, that it’s also just “fading the distance” with the depth buffer, it looks promising, but the AO gets faded away in the distance when there is no fog, so I’m back to square one. I think I will try to copy the builtin AO to the project and rewrite it with my AO effect.