Skip to content

Conversation

@JMS55
Copy link
Contributor

@JMS55 JMS55 commented Nov 21, 2025

Objective

  • Prevent world cache cells from querying each other and keeping each other alive infinitely
  • Now when you leave an area of your game, you're no longer paying performance cost for the out-of-view cells.
  • Also fix a long-standing off-by-1 bug in the world cache compaction code

Solution

  • Instead of always resetting cell lifetimes to the max lifetime during a cell query, for world cache update, we now set it to the max of the current cell lifetime and it's existing lifetime (max prevents a lower-lifetime cell overwriting a higher-lifetime cell).
  • Credit to IsaacSM and @NthTensor for the idea!

Testing

Video showing the current number of live world cache cells, before and after this PR.

Screen.Recording.2025-11-21.111911.mp4

@JMS55 JMS55 added this to the 0.18 milestone Nov 21, 2025
@JMS55 JMS55 added A-Rendering Drawing game state to the screen C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. labels Nov 21, 2025
@NthTensor
Copy link
Contributor

NthTensor commented Nov 21, 2025

Side note, we need to figure out why the bounce lighting isn't super visible in this test scene. Maybe @DGriffin91 knows?

@JMS55 JMS55 added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Nov 21, 2025
@JMS55
Copy link
Contributor Author

JMS55 commented Nov 21, 2025

Unfortunately this is a bit more expensive, likely because of the extra atomics. I'll have to test if copying the lifetime before the cell update to avoid the atomicLoad() improves things.

@JMS55
Copy link
Contributor Author

JMS55 commented Nov 21, 2025

Side note, we need to figure out why the bounce lighting isn't super visible in this test scene.

        DirectionalLight {
            illuminance: light_consts::lux::FULL_DAYLIGHT,
            shadows_enabled: false, // Solari replaces shadow mapping
            ..default()
        },

With default exposure.

@NthTensor
Copy link
Contributor

Unless we can find actual visual issues with using a store instead of a max, the store is probably acceptable. It just means we will be a bit more aggressive at clearing than is really necessary.

@JMS55
Copy link
Contributor Author

JMS55 commented Nov 21, 2025

atomicMax vs atomicStore doesn't seem to matter. I'm guessing the new atomicLoad is the problem, which is easy enough to fix.

@DGriffin91
Copy link
Contributor

Side note, we need to figure out why the bounce lighting isn't super visible in this test scene. Maybe @DGriffin91 knows?

Which version of the scene is this? By default all the materials are 100% metallic.

Side note: I'm not able to open the scene in bevy 0.17: #21490

@JMS55
Copy link
Contributor Author

JMS55 commented Nov 21, 2025

Figured out the performance changes, it's just from adjusting the maximum allowed cell lifetime. Not a big deal.

@JMS55
Copy link
Contributor Author

JMS55 commented Nov 21, 2025

Which version of the scene is this?

@SparkyPotato's on github. Your's wasn't updated at the time I set this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Refinement Improves output quality, without fixing a clear bug or adding new functionality. S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants