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 meshlet_visibility_buffer: texture_storage_2d<r64uint, read>;
5#else
6@group(0) @binding(0) var meshlet_visibility_buffer: texture_storage_2d<r32uint, read>;
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
11/// This pass writes out the depth texture.
12@fragment
13fn resolve_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
14 let visibility = textureLoad(meshlet_visibility_buffer, vec2<u32>(in.position.xy)).r;
15#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
16 let depth = u32(visibility >> 32u);
17#else
18 let depth = visibility;
19#endif
21 if depth == 0u { discard; }
23 return bitcast<f32>(depth);
26/// This pass writes out the material depth texture.
27#ifdef MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
28@fragment
29fn resolve_material_depth(in: FullscreenVertexOutput) -> @builtin(frag_depth) f32 {
30 let visibility = textureLoad(meshlet_visibility_buffer, vec2<u32>(in.position.xy)).r;
32 let depth = visibility >> 32u;
33 if depth == 0lu { discard; }
35 let cluster_id = u32(visibility) >> 7u;
36 let instance_id = meshlet_cluster_instance_ids[cluster_id];
37 let material_id = meshlet_instance_material_ids[instance_id];
38 return f32(material_id) / 65535.0;
40#endif
Contents