Skip to content

GTAONode: Fix false self-occlusion on distant slanted surfaces - #34718

Merged
Mugen87 merged 6 commits into
mrdoob:devfrom
EdoardoLuciani:fix/gtao-subpixel-self-occlusion
Oct 1, 2026
Merged

Mugen87 merged 6 commits into
mrdoob:devfrom
EdoardoLuciani:fix/gtao-subpixel-self-occlusion

Conversation

@EdoardoLuciani

@EdoardoLuciani EdoardoLuciani commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Related issue: -

Description

I noticed that the AO pass falsely occludes distant slanted objects.

Root cause: Sampled depth in the shader belongs to the selected texel center, not necessarily to rayUV.

Fix: Snap ray UVs to depth-texel centers using the depth texture’s dimensions, then use those UVs for both sampling and reconstruction.

AO comparison

Scene Before After
Isolated wall, 75° / 60 m Before: test scene raw AO After: test scene raw AO
Claude of Duty (my game) Before: game scene raw AO After: game scene raw AO

Isolated-wall centre visibility: 0.631 → 0.968 (ideal: 1).

Performance

Game scene, Chrome 153, Linux, WebGPU, 960×540 high; Frame intervals in ms (p50 / p95 / p99):

GPU Before After
RX 9070 XT 25.3 / 90.5 / 154.6 25.1 / 87.7 / 155.9
Ryzen integrated 133.1 / 192.5 / 234.9 133.3 / 178.3 / 236.3

- Remove temporary render-target variables used only for readback.
- Reuse the wall material for the identical blocker instead of allocating and disposing a second material.
- Remove the redundant render-target reset from fixture disposal.

Keep all shader guards, regression cases, assertions, and resource ownership. All 42 visibility readbacks match before/after on both physical GPUs.
Preserve the manual GPU harness on repro/gtao-subpixel-self-occlusion rather than adding a standalone test entry point to the shader-fix PR.

Match surrounding comment spacing and center terminology, and place the sample-validation explanation alongside the shared rule.

No existing upstream tests, test registration, shader behavior, or generated files are changed.
@EdoardoLuciani
EdoardoLuciani marked this pull request as ready for review September 30, 2026 14:32
@Mugen87

Mugen87 commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

At what resolution scale are you using GTAONode?

@EdoardoLuciani

EdoardoLuciani commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for the quick follow-up!

In the above screenshots I used resolutionScale = 1.
I just tested again and the degradation does not reproduce at 0.5 or 0.25. These are the mean raw AO visibility values:

resolutionScale Before After
1 0.6310 0.9682
0.5 0.9904 0.9904
0.25 0.9904 0.9904

I believe its due to pixel-grid alignment, at full resolution AO pixel centres line up with depth pixel centres. At half and quarter resolution, they fall between depth pixel centers.

@Mugen87

Mugen87 commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

That's why I asked. When resolution scale is lower than 1, we use use a texture gather which automatically prevents the issue from appearing. I now wondering if we should use a different code path for the full resolution case...

The "off-screen check" is actually useful for any resolution scale. I'll try to refactor the code a bit.

@Mugen87

Mugen87 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Can you please test the new version? Is the quality improvement still in place?

I think the snap is not required to fix the visuals. The bug came mainly from samples that land inside the center texel (and these are still rejected).

@Mugen87 Mugen87 added this to the r187 milestone Sep 30, 2026
@EdoardoLuciani

Copy link
Copy Markdown
Contributor Author

Thanks! I retested your latest commit on the slanted wall and the main improvement is still there.

I'm happy with your changes - I agree it’s a better minimal fix.

Raw AO visibility for the isolated wall at resolutionScale = 1:

Angle Stock With snapping Your refactor
45 0.853512 0.991333 0.986248
75 0.631024 0.968153 0.955335
85 0.545508 0.956361 0.942463

@Mugen87

Mugen87 commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Glad to hear that! I think what we have now is a well balanced change that solves the reported issue but in a minimal invasive way. And the "off-screen check" is something beneficial for every code path.

@Mugen87
Mugen87 merged commit 6b0d348 into mrdoob:dev Oct 1, 2026
9 checks passed
@EdoardoLuciani
EdoardoLuciani deleted the fix/gtao-subpixel-self-occlusion branch October 2, 2026 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants