Skip to content

Conversation

querielo
Copy link
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 Copilot AI review requested due to automatic review settings July 20, 2025 15:17
Copy link

@Copilot Copilot AI left a comment

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

@Mugen87 Mugen87 added this to the r179 milestone Jul 20, 2025
@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
Copy link
Collaborator

sunag commented Jul 20, 2025

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

@Mugen87
Copy link
Collaborator

Mugen87 commented Jul 21, 2025

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.

3 participants