Skip to content

SSAOPass: Replace visibility cache Map with an array for improved performance#31453

Merged
Mugen87 merged 3 commits into
mrdoob:devfrom
querielo:ssao-override-visibility
Jul 20, 2025
Merged

SSAOPass: Replace visibility cache Map with an array for improved performance#31453
Mugen87 merged 3 commits into
mrdoob:devfrom
querielo:ssao-override-visibility

Conversation

@querielo

Copy link
Copy Markdown
Contributor

This PR refactors the SSAOPass class in examples/jsm/postprocessing/SSAOPass.js to improve how object visibility is cached and restored during the SSAO pass. It improves performance and clarity by only tracking objects whose visibility is actually modified.

We can reduce the SSAO pass render time by nearly 40-50%.

The dev branch PR
Screenshot 2025-07-20 at 17 00 50 Screenshot 2025-07-20 at 17 07 46

Copilot AI review requested due to automatic review settings July 20, 2025 15:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the SSAOPass visibility caching system to improve performance by replacing the Map-based cache with an array that only stores objects whose visibility is actually modified. The change eliminates the need to traverse all scene objects during restoration and reduces memory overhead.

  • Replaces Map-based visibility cache with array for better performance
  • Only caches objects that have their visibility modified (Points, Line, Line2 objects)
  • Optimizes restoration by iterating only cached objects instead of entire scene

Comment thread examples/jsm/postprocessing/SSAOPass.js Outdated
@Mugen87 Mugen87 added this to the r179 milestone Jul 20, 2025
Comment thread examples/jsm/postprocessing/SSAOPass.js Outdated
@Mugen87 Mugen87 merged commit 3e77c57 into mrdoob:dev Jul 20, 2025
8 checks passed
Mugen87 pushed a commit that referenced this pull request Jul 20, 2025
…formance (#31454)

* GTAOPass: Replace visibility cache Map with an array for improved performance

* GTAOPass: review comment #31453 (comment)
@sunag

sunag commented Jul 20, 2025

Copy link
Copy Markdown
Collaborator

@Mugen87 There was some reason to use renderer.setRenderObjectFunction() instead of scene.traverse()?

@Mugen87

Mugen87 commented Jul 21, 2025

Copy link
Copy Markdown
Collaborator

These are the "old" post porcessing classes for WebGLRenderer where setRenderObjectFunction() isn't available.

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.

4 participants