-
-
Notifications
You must be signed in to change notification settings - Fork 20.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement indirect specular occlusion in StandardMaterial3D #50601
Conversation
199500c
to
0c5d308
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great as a start!
However, I don't think we should force light_affect to 1.0 for specular lighting. Light_affect is already kind of a specific hack that will only be used by some, I don't think we should force it on all users with no way to turn off.
An alternative is to separate direct specular from indirect specular and then combine them after you have applied AO to specular_light
. Separating the two will also probably be desirable as we polish other rendering features.
This comment has been minimized.
This comment has been minimized.
7f34736
to
bcfd742
Compare
Rebased and tested again, it works as expected. New screenshots were added to OP, along with a testing project. Let me know if I should add an Environment property to adjust specular AO intensity, though I'd prefer the effect to be enabled by default. If the unused Ao Channel Affect Environment property is removed, this should free up some space in the Environment inspector anyway. |
bcfd742
to
2a82e66
Compare
This PR still has the problem that it treats direct and indirect specular the same. It is darkening both direct and indirect by the full amount of ao regardless of the |
2a82e66
to
2a21625
Compare
I managed to separate direct specular lighting from indirect specular lighting and use the Filament approximation. See OP for updated screenshots 🙂 However, this appears to have a significant performance cost (0.2 ms of added frame time in my test scene, with SSAO and height mapping disabled). I expected it to be cheaper, given the description on the Filament website. I've tried to move If I remove the Filament approximation but keep the indirect specular multiplication based on original AO, I get the exact same result (but with better performance): SSAO + heightNo SSAO and heightDifference with original "After" imagesThe images are bit-for-bit identical:
Note that I still need to port the changes to the mobile renderer. |
2a21625
to
087c774
Compare
Rebased and tested again, it works as expected. I've updated screenshots in OP. Note that this comment still applies. |
This uses the approximation from Filament. Direct specular lighting (such as light specular lobes) are not affected. Both sources of AO (SSAO and AO texture maps) are used for this effect. The difference is most noticeable when SSAO is enabled (especially with height maps), but this effect also helps when SSAO is disabled. It is an approximate effect with a low performance cost, but it makes specular reflections more believable overall.
087c774
to
d2899b8
Compare
master
version of #50603.Both sources of AO (SSAO and AO texture maps) are used for this effect. The difference is most noticeable when SSAO is enabled (especially with height maps), but this effect also helps when SSAO is disabled.
It is an approximate effect with a very low performance cost, but makes specular reflections more believable overall.
Testing project: test_ao_specular_occlusion_master.zip
Preview
SSAO intensity was doubled to make the difference more noticeable. In real world scenarios, the difference will be more subtle.
Light Affect is set to 0 (default) both in the SSAO and material settings.
Left: partially metallic material (0.5), right: fully metallic material (1.0)
SSAO and height enabled
Forward+
Mobile1
No SSAO and no height (only AO map in material)
Forward+
Mobile1
Footnotes
This currently uses a faster, but supposedly more approximate approach to indirect specular occlusion. ↩ ↩2