-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Solari: Light leak reduction and stochastic WC update #22348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alice-i-cecile
merged 9 commits into
bevyengine:main
from
JMS55:solari6-light-leak-final
Jan 13, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
542f32b
Solari: Light leak reduction and stochastic WC update
JMS55 0b77251
Misc refactors
JMS55 51f950a
Only limit cell size on first bounce
JMS55 dfec460
Fix
JMS55 0f50f7b
Re-enable world cache jitter (maybe we should try only doing it for c…
JMS55 cb05080
Merge commit '1384bcbd07fd8515469d925849d1fcff467c1377' into solari6-…
JMS55 da885d0
Merge commit 'b1d1b2c03f80109c3574987de0e4c8246709ddf6' into solari6-…
JMS55 1079324
Misc rename
JMS55 f67489f
Fix merge
JMS55 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,27 +21,37 @@ const WORLD_CACHE_MAX_TEMPORAL_SAMPLES: f32 = 32.0; | |
| const WORLD_CACHE_DIRECT_LIGHT_SAMPLE_COUNT: u32 = 32u; | ||
| /// Maximum amount of distance to trace GI rays between two cache cells | ||
| const WORLD_CACHE_MAX_GI_RAY_DISTANCE: f32 = 50.0; | ||
| /// Soft upper limit on the amount of cache cells to update each frame | ||
| const WORLD_CACHE_CELL_UPDATES_SOFT_CAP: u32 = 40000u; | ||
|
|
||
| /// Maximum amount of frames a cell can live for without being queried | ||
| const WORLD_CACHE_CELL_LIFETIME: u32 = 30u; | ||
| const WORLD_CACHE_CELL_LIFETIME: u32 = 10u; | ||
| /// Maximum amount of attempts to find a cache entry after a hash collision | ||
| const WORLD_CACHE_MAX_SEARCH_STEPS: u32 = 3u; | ||
|
|
||
| /// Size of a cache cell at the lowest LOD in meters | ||
| const WORLD_CACHE_POSITION_BASE_CELL_SIZE: f32 = 0.25; | ||
| const WORLD_CACHE_POSITION_BASE_CELL_SIZE: f32 = 0.15; | ||
| /// How fast the world cache transitions between LODs as a function of distance to the camera | ||
| const WORLD_CACHE_POSITION_LOD_SCALE: f32 = 8.0; | ||
| const WORLD_CACHE_POSITION_LOD_SCALE: f32 = 15.0; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how hard will it be to make all these constants uniforms tweakable from Resource someday?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easy, just not a priority atm. It's on the tracking issue. |
||
|
|
||
| /// Marker value for an empty cell | ||
| const WORLD_CACHE_EMPTY_CELL: u32 = 0u; | ||
|
|
||
| #ifndef WORLD_CACHE_NON_ATOMIC_LIFE_BUFFER | ||
| fn query_world_cache(world_position_in: vec3<f32>, world_normal: vec3<f32>, view_position: vec3<f32>, cell_lifetime: u32, rng: ptr<function, u32>) -> vec3<f32> { | ||
| fn query_world_cache(world_position_in: vec3<f32>, world_normal: vec3<f32>, view_position: vec3<f32>, ray_t: f32, cell_lifetime: u32, rng: ptr<function, u32>) -> vec3<f32> { | ||
| var world_position = world_position_in; | ||
| var cell_size = get_cell_size(world_position, view_position); | ||
|
|
||
| #ifdef WORLD_CACHE_FIRST_BOUNCE_LIGHT_LEAK_PREVENTION | ||
| if ray_t < cell_size { | ||
| // Prevent light leaks | ||
| cell_size = WORLD_CACHE_POSITION_BASE_CELL_SIZE; | ||
| } | ||
| #endif | ||
|
|
||
| #ifndef NO_JITTER_WORLD_CACHE | ||
| // Jitter query point, which essentially blurs the cache a bit so it's not so grid-like | ||
| // https://tomclabault.github.io/blog/2025/regir, jitter_world_position_tangent_plane | ||
| #ifdef JITTER_WORLD_CACHE | ||
| let TBN = orthonormalize(world_normal); | ||
| let offset = (rand_vec2f(rng) * 2.0 - 1.0) * cell_size * 0.5; | ||
| world_position += offset.x * TBN[0] + offset.y * TBN[1]; | ||
|
|
||
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.