Skip to content

Fix GPU-clustered decals vanishing at steep camera pitch#24954

Open
Ijtihed wants to merge 1 commit into
bevyengine:mainfrom
Ijtihed:fix/gpu-clustering-degenerate-far-z
Open

Fix GPU-clustered decals vanishing at steep camera pitch#24954
Ijtihed wants to merge 1 commit into
bevyengine:mainfrom
Ijtihed:fix/gpu-clustering-degenerate-far-z

Conversation

@Ijtihed

@Ijtihed Ijtihed commented Jul 11, 2026

Copy link
Copy Markdown

Objective

Fixes #24918. with GPU clustering on

Solution

When the camera looks steeply down everything visible is closer than the first slice depth so assign_objects_to_clusters clamps the grid's far down to near. calculate_cluster_factors then divides by ln(far / near) == 0 and the factors go infinite.

the shader (cluster_raster.wgsl) rebuilt z_near/z_far back out of those factors with exp() and exp(inf / inf) is NaN so every cluster/object intersection test failed and nothing got clustered. (that rebuild was also broken for single Z slice grids.)

this just passes near/far to the shader directly in a new cluster_z_bounds field on the Lights uniform and drops the shader-side rebuild. #23438 is in the same area but a separate bug.

Testing

madethe issue's scene and rendered it at fixed pitches on Linux/Vulkan (GTX 1660 SUPER) and counted decal pixels. before: 0 decal pixels from -50 to -90 degrees. after: matches the CPU clustering path exactly at every pitch. the interactive repro from #24918 also confirms it (decals gone past ~-50, SPACE toggles CPU clustering and brings them back with the fix both look the same)


Showcase

straight down (-90) GPU clustering, before vs after:

before after

@github-actions

Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 12, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Jul 12, 2026
@pcwalton pcwalton self-requested a review July 13, 2026 17:37
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-Bug An unexpected or incorrect behavior S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

Clustered decals vanish at steep camera pitch when GPU clustering is active

2 participants