Skip to content

Commit 7c60387

Browse files
zeuxmockersf
authored andcommitted
Fix incorrect computation of mips for cluster occlusion lookup (#14042)
The comment was incorrect - we are already looking at the pyramid texture so we do not need to transform the size in any way. Doing that resulted in a mip that was too fine to be selected in certain cases, which resulted in a 2x2 pixel footprint not actually fully covering the cluster sphere - sometimes this could lead to a non-conservative depth value being computed which resulted in the cluster being marked as invisible incorrectly.
1 parent 5d7da82 commit 7c60387

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/bevy_pbr/src/meshlet/cull_clusters.wgsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ fn cull_clusters(
8585
let culling_bounding_sphere_center_view_space = (view.view_from_world * vec4(culling_bounding_sphere_center.xyz, 1.0)).xyz;
8686

8787
let aabb = project_view_space_sphere_to_screen_space_aabb(culling_bounding_sphere_center_view_space, culling_bounding_sphere_radius);
88-
// Halve the view-space AABB size as the depth pyramid is half the view size
89-
let depth_pyramid_size_mip_0 = vec2<f32>(textureDimensions(depth_pyramid, 0)) * 0.5;
88+
let depth_pyramid_size_mip_0 = vec2<f32>(textureDimensions(depth_pyramid, 0));
9089
let width = (aabb.z - aabb.x) * depth_pyramid_size_mip_0.x;
9190
let height = (aabb.w - aabb.y) * depth_pyramid_size_mip_0.y;
9291
let depth_level = max(0, i32(ceil(log2(max(width, height))))); // TODO: Naga doesn't like this being a u32

0 commit comments

Comments
 (0)