Repository navigation
ssao: reconstruct SAO taps at their depth texel - #10881
Merged
Merged
Conversation
SAO reads a tap's depth with nearest filtering, so the depth belongs to one texel's center, and each depth mip keeps one texel of each 2x2 block. The tap's position was rebuilt at its own sub-texel uv, so on a surface at an angle to the view the point lay up to a texel's depth change off the surface. Points in front counted as occlusion and points behind were clamped to zero, so flat, open surfaces got ambient occlusion that grew as the AO buffer got smaller. Rebuild each tap at the center of the level-0 texel its depth comes from. Fixes google#10880 RDIFF_ACCEPT_NEW_GOLDENS
Contributor
|
Thanks! That's a great fix |
Contributor
|
@jeongseok-meta Can you add |
poweifeng
approved these changes
Nov 24, 2026
Comment on lines
+37
to
+40
| // A nearest-filtered sample at uv returns the depth of one texel's center, and each mip level | ||
| // holds the depth of one texel of the 2x2 block below it (see mipmapDepth.mat). This returns the | ||
| // uv of the center of the level-0 texel that depth comes from. A position reconstructed there | ||
| // lies on the surface; reconstructed at uv itself, it lies up to a texel's depth change off it. |
Contributor
There was a problem hiding this comment.
nit: could really use a more human comment here (maybe tell ai to write in asd-ste100?)
jeongseok-meta
force-pushed
the
fix-sao-texel-center
branch
from
November 25, 2026 02:52
4efcd4c to
ecaea7d
Compare
Contributor
Author
|
Added it to the commit message, and simplified the comments. |
show50726
approved these changes
Nov 25, 2026
romainguy
enabled auto-merge (squash)
November 25, 2026 07:08
Contributor
|
There seems to be an unrelated test failure: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #10880.
SAO reads each tap's depth with nearest filtering, so the depth belongs to one texel's center, and each depth mip keeps one texel of each 2x2 block (
mipmapDepth.mat).computeAmbientOcclusionSAO()rebuilt the tap's position at the tap's own sub-texel uv instead. On a surface at an angle to the view, that point lies up to a texel's depth change off the surface; the points in front count as occlusion and the ones behind are clamped to zero, so flat, open surfaces got ambient occlusion that grew as the AO buffer got smaller.The new
depthTexelUV()inssaoUtils.fsreturns the uv of the center of the level-0 texel whose depth the sample returned: it followsmipmapDepth.mat's choice in each 2x2 block back to level 0. SAO rebuilds each tap there, so the point lies on the surface.Far wall of the repro in #10880 (mean value, linear output, post-processing off):
Real occlusion stays. At the crease between that wall and the floor, SSAO off reads 15.7; after the change it reads 11.1 to 12.7 across the four sizes (before: 8.5 to 12.0). Next to a box standing on the floor, SSAO off reads 23.8; after, 19.6 to 20.8.
Testing:
saoImpl.fsandssaoUtils.fsare the same on main) and ran the repro on Vulkan (Mesa lavapipe, NVIDIA A100) and OpenGL (A100): the table above on every backend. Its check (the far wall reads within half a value of SSAO off at 256 and 1024 px) fails before this change and passes after.matccompilessao,saoBentNormals,gtao,gtaoBentNormals,bilateralBlurandbilateralBlurBentNormalsfor OpenGL, Vulkan and Metal, desktop and mobile. I didn't build WebGPU.GTAO reads depth the same way but is hardly affected by it (15.97 to 16.0 on the same wall). Rebuilding its taps at texel centers made it noisier there, so this change leaves GTAO as it is.