[Rendering] fix: guard the bright pass against infinities and NaNs - #3429
Merged
Merged
Conversation
The bright filter's output goes through a pyramid of half-float targets. A value above 65504 becomes an infinity there, the first zero blur weight turns it into a NaN, and the NaN spreads across the kernel as a black block the size of the mip it happened on. Luma already floored negatives; nothing capped the other end. The bright filter and the range compressor clamp to 32000, half a half-float's ceiling, through a shared HalfPrecisionUtils.ClampToSafeRange. Written as a select on a comparison rather than min/max: a NaN fails the comparison and becomes 0 on every backend, where min/max on a NaN is undefined in SPIR-V. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
3 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR Details
Split out of #3387, per review.
The bright filter's output is downsampled and blurred through a pyramid of half-float targets. A value above 65504 becomes an infinity there, the first zero blur weight turns it into a NaN, and the NaN spreads across the kernel as a black block the size of the mip it happened on. Luma already floored negatives; nothing capped the other end.
HalfPrecisionUtils.ClampToSafeRange.color > 0.0 ? min(color, MaxSafeValue) : 0.0: a per-component select, so no branch, and a NaN fails the comparison and becomes 0 on every backend.min/maxon a NaN is undefined in SPIR-V, so the earliermin(max(...))form only worked on Direct3D.Verified on Direct3D 11 with the voxel GI demo, bloom on: no black blocks, same image otherwise.
Related Issue
#3387
Types of changes
Checklist