-
Notifications
You must be signed in to change notification settings - Fork 238
[DDGI] Stability Improvement for ComputeVisibility(): Added Stabilizer for variance floor & Delta Clamp to avoid tails #9919
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Improves numerical stability of DDGI visibility computation by adding a variance floor and clamping the distance delta to reduce extreme-tail behavior.
Changes:
- Adds a variance “stabilizer” floor based on
mean^2. - Clamps
deltatomean * 3.0fbefore computing Chebyshev visibility.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| variance = max(variance, 0.0001f * mean * mean); | ||
|
|
||
| float delta = max(distanceToSample - mean, 0.0f); | ||
| delta = min(delta, mean * 3.0f); //Tries to avoid tails @test if neccesary |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delta = min(delta, mean * 3.0f) can clamp delta to 0 when mean is 0 (or very small), which makes chebyshev become variance/(variance+0) (often 1) and can even produce 0/0 NaNs when variance is also 0. Since probe distance moments can legitimately have mean == 0 (e.g., empty/invalid samples), clamp using an epsilon (e.g., max(mean, eps)), clamp to an absolute distance, or gate the clamp so it only applies when mean is above a threshold.
| delta = min(delta, mean * 3.0f); //Tries to avoid tails @test if neccesary | |
| // Clamp delta using a safe mean to avoid forcing delta to 0 when mean is 0 (or very small) | |
| float meanForClamp = max(mean, 0.001f); | |
| delta = min(delta, meanForClamp * 3.0f); // Tries to avoid tails @test if necessary |
|
|
||
| // Minimal stabilizer | ||
| variance = max(variance, 0.0001f * mean * mean); | ||
|
|
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added lines use tab indentation and introduce trailing whitespace, while surrounding code in this file uses spaces. Please re-indent these lines to match the file’s existing spacing to avoid noisy diffs and style inconsistencies.
| variance = max(variance, 0.0001f * mean * mean); | ||
|
|
||
| float delta = max(distanceToSample - mean, 0.0f); | ||
| delta = min(delta, mean * 3.0f); //Tries to avoid tails @test if neccesary |
Copilot
AI
Jan 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment has spelling/wording issues (e.g., "neccesary") and includes internal notes like "@test" that read as temporary. Please correct the spelling and either remove the TODO-style note or turn it into a clear, actionable comment describing when/why the clamp should be enabled.
| delta = min(delta, mean * 3.0f); //Tries to avoid tails @test if neccesary | |
| delta = min(delta, mean * 3.0f); // Clamp delta to limit tail contribution and stabilize visibility; adjust the factor if stronger tail suppression is necessary. |
|
Seems right, can't find any meaningful difference even in edge case tests though, could you give more details on the edge cases this is solving |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
This PR has been merged upstream. |

Added Stabilizer for variance floor & Delta Clamp to avoid tails