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
2#import bevy_pbr::meshlet_bindings::InstancedOffset
4#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
5@group(0) @binding(0) var meshlet_visibility_buffer: texture_storage_2d<r64uint, read>;
6#else
7@group(0) @binding(0) var meshlet_visibility_buffer: texture_storage_2d<r32uint, read>;
8#endif
9@group(0) @binding(1) var<storage, read> meshlet_raster_clusters: array<InstancedOffset>; // Per cluster
10@group(0) @binding(2) var<storage, read> meshlet_instance_material_ids: array<u32>; // Per entity instance
12/// This pass writes out the depth texture.
13@fragment
14fn resolve_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
15 let visibility = textureLoad(meshlet_visibility_buffer, vec2<u32>(in.position.xy)).r;
16#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
17 let depth = u32(visibility >> 32u);
18#else
19 let depth = visibility;
20#endif
22 if depth == 0u { discard; }
24 return bitcast<f32>(depth);
27/// This pass writes out the material depth texture.
28#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
29@fragment
30fn resolve_material_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
31 let visibility = textureLoad(meshlet_visibility_buffer, vec2<u32>(in.position.xy)).r;
33 let depth = visibility >> 32u;
34 if depth == 0lu { discard; }
36 let cluster_id = u32(visibility) >> 7u;
37 let instance_id = meshlet_raster_clusters[cluster_id].instance_id;
38 let material_id = meshlet_instance_material_ids[instance_id];
39 return f32(material_id) / 65535.0;
41#endif
Contents