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#import bevy_core_pipeline::fullscreen_vertex_shader::FullscreenVertexOutput
3#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
4@group(0) @binding(0) var<storage, read> meshlet_visibility_buffer: array<u64>; // Per pixel
5#else
6@group(0) @binding(0) var<storage, read> meshlet_visibility_buffer: array<u32>; // Per pixel
7#endif
8@group(0) @binding(1) var<storage, read> meshlet_cluster_instance_ids: array<u32>; // Per cluster
9@group(0) @binding(2) var<storage, read> meshlet_instance_material_ids: array<u32>; // Per entity instance
10var<push_constant> view_width: u32;
12/// This pass writes out the depth texture.
13@fragment
14fn resolve_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
15 let frag_coord_1d = u32(in.position.y) * view_width + u32(in.position.x);
16 let visibility = meshlet_visibility_buffer[frag_coord_1d];
17#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
18 return bitcast<f32>(u32(visibility >> 32u));
19#else
20 return bitcast<f32>(visibility);
21#endif
24/// This pass writes out the material depth texture.
25#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
26@fragment
27fn resolve_material_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
28 let frag_coord_1d = u32(in.position.y) * view_width + u32(in.position.x);
29 let visibility = meshlet_visibility_buffer[frag_coord_1d];
31 let depth = visibility >> 32u;
32 if depth == 0lu { return 0.0; }
34 let cluster_id = u32(visibility) >> 7u;
35 let instance_id = meshlet_cluster_instance_ids[cluster_id];
36 let material_id = meshlet_instance_material_ids[instance_id];
37 return f32(material_id) / 65535.0;
39#endif
Contents