Skip to content

[Rendering] fix: guard the bright pass against infinities and NaNs - #3429

Merged
xen2 merged 1 commit into
stride3d:masterfrom
Nicogo1705:bright-pass-clamp
Sep 13, 2026
Merged

xen2 merged 1 commit into
stride3d:masterfrom
Nicogo1705:bright-pass-clamp

Conversation

@Nicogo1705

Copy link
Copy Markdown
Contributor

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.

  • The bright filter and the range compressor clamp to 32000, half a half-float's ceiling, through a shared HalfPrecisionUtils.ClampToSafeRange.
  • Written as 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/max on a NaN is undefined in SPIR-V, so the earlier min(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

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

⚠️ Written with AI assistance (Claude Code), driven and verified by me; needs a real review. 🤖 Generated with Claude Code

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>
@xen2
xen2 merged commit 237b284 into stride3d:master Sep 13, 2026
32 checks passed
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.

2 participants