Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1//! Occlusion culling utility functions.
3fn get_aabb_size_in_pixels(aabb: vec4<f32>, depth_pyramid: texture_2d<f32>) -> vec2<f32> {
4 let depth_pyramid_size_mip_0 = vec2<f32>(textureDimensions(depth_pyramid, 0));
5 let aabb_width_pixels = (aabb.z - aabb.x) * depth_pyramid_size_mip_0.x;
6 let aabb_height_pixels = (aabb.w - aabb.y) * depth_pyramid_size_mip_0.y;
7 return vec2(aabb_width_pixels, aabb_height_pixels);
8}
10fn get_occluder_depth(
11 aabb: vec4<f32>,
12 aabb_pixel_size: vec2<f32>,
13 depth_pyramid: texture_2d<f32>
14) -> f32 {
15 let aabb_width_pixels = aabb_pixel_size.x;
16 let aabb_height_pixels = aabb_pixel_size.y;
18 let depth_pyramid_size_mip_0 = vec2<f32>(textureDimensions(depth_pyramid, 0));
19 let depth_level = max(0, i32(ceil(log2(max(aabb_width_pixels, aabb_height_pixels))))); // TODO: Naga doesn't like this being a u32
20 let depth_pyramid_size = vec2<f32>(textureDimensions(depth_pyramid, depth_level));
21 let aabb_top_left = vec2<u32>(aabb.xy * depth_pyramid_size);
23 let depth_quad_a = textureLoad(depth_pyramid, aabb_top_left, depth_level).x;
24 let depth_quad_b = textureLoad(depth_pyramid, aabb_top_left + vec2(1u, 0u), depth_level).x;
25 let depth_quad_c = textureLoad(depth_pyramid, aabb_top_left + vec2(0u, 1u), depth_level).x;
26 let depth_quad_d = textureLoad(depth_pyramid, aabb_top_left + vec2(1u, 1u), depth_level).x;
27 return min(min(depth_quad_a, depth_quad_b), min(depth_quad_c, depth_quad_d));
Contents