Add specular occlusion term from AO and Bent Normals and use Bent Normals for indirect lighting
Closes https://github.com/godotengine/godot-proposals/issues/9401
Based on #50601
This implements approximate specular occlusion either from just ambient occlusion (from a texture, SSAO or otherwise) or ambient occlusion and cosine weighted bent normals. When bent normals are provided they will also be used for indirect lighting.
Forward+ implements the full complex implementation while mobile has a simpler calculation.
Examples (SSAO is enabled, SSR are not):
| Forward+ | Mobile |
|---|---|
Comparison with master (Forward+, SSR and SSAO enabled)
For clarification: "Inaccurate shader" in this case is a shader that calculates the bent normal occlusion but wrongly applies it as a multiplier for the AO and SPECULAR constant.
Test project:
Applied all the review notes
You ignored quite a bit of those notes, they were relevant details like comment style and code formatting, it's important to pay attention to the details
That's my bad, I'll go over them again
Realized you had used mixed indentation in your code so updated my suggestion to fix that
Apologies about all the issues with the shader file formatting This is my first time working on these
It's understandable, that's what we're here for :)
Why the effect is so different in mobile than forward?
Why the effect is so different in mobile than forward?
It's a simpler calculation than forward+ I wouldn't mind putting the same calculation as forward+ into the mobile shader but it might perform badly with the cos and acos calls
I fixed an error in using the direct light affect slider modified AO in the bent normal specular occlusion calculation instead of the baseline AO. This is now accurate to the paper referenced in the code.
This does not affect the previous test, as the approximation with AO only is still the same.
| Before | After |
|---|---|
I added a comment linking a PDF of the paper mentioned for spherical cap intersections. This paper was only briefly mentioned in the main paper so I thought it'd be a good addition.
I created a small scene with CC0 models from polyhaven that I also generated bent normals for. This should make testing this PR easier.
The project has TAA, SSAO, SSIL and SDFGI enabled by default.