-
-
Notifications
You must be signed in to change notification settings - Fork 36k
WebGLRenderer: Improve ambient occlusion handling in PBR materials. #32067
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
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I work on the machine configuration myMachine.dmgmori.com with extensive use of baked AO absolutely everywhere. Can there be a toggle for this? Or a can the Energy mix in the shader become a uniform controllable via JS through Material Properties? Before the PR, I also noticed AO being stronger than expected, especially on metals. With this PR the swings quite hard the other way though, makes interior surfaces under oblique angles glow, with the environment coming through strong for surfaces which were very AO Shaded before, AO baked lighting didn't make it into before. So with this change I would have to setup an extra environment probe for machine insides to avoid this. Inside
Notice the glow on back wall and oblique angle panels of the spindles. Outside
Panel Gaps at oblique angles
Panel gaps, which were previously fully occluded by their panel surroundings now start to glow, as they "reclaim" that energy by virtue of being seen at an oblique angle |
vec3 multiBounce = ( ( x * a + b ) * x + c ) * x; | ||
// Blend between simple AO and multi-bounce (50/50) to keep it conservative | ||
return mix( vec3( x ), max( vec3( x ), multiBounce ), 0.5 ); |
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.
Would love for this 50% to be tweak-able uniform. or the whole computeSpecularOcclusionImproved to be a glsl fragment in-off itself, so it could be dynamically disabled, similar to how Tone-Mapping is a dynamically included or excluded glsl fragment.
Thanks for testing! Can you check if #32073 works better for you? |
@mrdoob
In #32073 Because of how AO blends, it appears like a strong contrast boost! Try looking in Working Space --> Right Spindle. Also switch to a tail stock, as these have a comparison between dark and bright metals. On the bright side, the Oblique angles aren't "lightleak" like bright anymore heh.
Without oblique angles, the AO is pitch black, where light was before. But at oblique angles the deletion is stronger --> "Contrast boost" effect.
Also, Metal with AO + Very Oblique angle + multibounce-ao-specular = pitch black again.
Compared to v0.180.0, multibounce-ao-specular tends to influence AO more and create a discontinuity, making AO change based on viewing angle. This was also previously the case, but now it "appears like the shadow not being applied correclty" at certain angles more often than not. Here Occlusion is the the same on both panels, but due to angle changes they appear "discontinuous". This was totally the case before as well, reflections overpowering AO (as they should), but now it happens more often, or maybe the darkening is coming through stronger on one panel than the other, more often than not. It's all a bit vague, Asset dependent. Direct browser comparisons make this a bit more clear.
|
Super useful! Thanks! 🙏 Damn, we sure lack good examples that test all this... |
Thank you! Any chance you could do another |
Oh, but I wonder what does the PathTracer do with the AO baked in the texture... @gkjohnson Does it ignore it? Or does it take into account when rendering? |
Physically correct would be without |
Yeah AO maps are ignored in the path tracer. |
Description
This PR enhances the ambient occlusion implementation in physical materials with two improvements:
1. Multi-bounce AO approximation
2. Improved specular occlusion with horizon fading
These changes make AO integration more physically accurate while maintaining the overall occlusion effect. The improvements are most noticeable on models with baked AO maps, particularly on bright materials and at object edges.
For comparison:
https://raw.githack.com/mrdoob/three.js/dev/examples/index.html#webgl_animation_keyframes
https://raw.githack.com/mrdoob/three.js/multibounce-ao/examples/index.html#webgl_animation_keyframes
https://raw.githack.com/mrdoob/three.js/dev/examples/index.html?q=gltf#webgl_loader_gltf_compressed
https://raw.githack.com/mrdoob/three.js/multibounce-ao/examples/index.html?q=gltf#webgl_loader_gltf_compressed
https://raw.githack.com/mrdoob/three.js/dev/examples/index.html#webgl_random_uv
https://raw.githack.com/mrdoob/three.js/multibounce-ao/examples/index.html#webgl_random_uv