Back home 🏡 WGSL Spec Bevy WGSL Functions

meshlet_bindings.wgsl

Import path

Constants

Name Type Value
CENTIMETERS_PER_METER # AbstractFloat 100.0

Bindings

Name Group Binding index Binding type Type Shader Def
meshlet_instance_meshlet_counts # 0 0 <storage, read> array<u32> 🟢 MESHLET_FILL_CLUSTER_BUFFERS_PASS
meshlet_instance_meshlet_slice_starts # 0 1 <storage, read> array<u32> 🟢 MESHLET_FILL_CLUSTER_BUFFERS_PASS
meshlet_cluster_instance_ids # 0 2 <storage, read_write> array<u32> 🟢 MESHLET_FILL_CLUSTER_BUFFERS_PASS
meshlet_cluster_meshlet_ids # 0 3 <storage, read_write> array<u32> 🟢 MESHLET_FILL_CLUSTER_BUFFERS_PASS
meshlet_global_cluster_count # 0 4 <storage, read_write> atomic<u32> 🟢 MESHLET_FILL_CLUSTER_BUFFERS_PASS
meshlet_cluster_meshlet_ids # 0 0 <storage, read> array<u32> 🟢 MESHLET_CULLING_PASS
meshlet_bounding_spheres # 0 1 <storage, read> array<MeshletBoundingSpheres> 🟢 MESHLET_CULLING_PASS
meshlet_simplification_errors # 0 2 <storage, read> array<u32> 🟢 MESHLET_CULLING_PASS
meshlet_cluster_instance_ids # 0 3 <storage, read> array<u32> 🟢 MESHLET_CULLING_PASS
meshlet_instance_uniforms # 0 4 <storage, read> array<Mesh> 🟢 MESHLET_CULLING_PASS
meshlet_view_instance_visibility # 0 5 <storage, read> array<u32> 🟢 MESHLET_CULLING_PASS
meshlet_second_pass_candidates # 0 6 <storage, read_write> array<atomic<u32>> 🟢 MESHLET_CULLING_PASS
meshlet_software_raster_indirect_args # 0 7 <storage, read_write> DispatchIndirectArgs 🟢 MESHLET_CULLING_PASS
meshlet_hardware_raster_indirect_args # 0 8 <storage, read_write> DrawIndirectArgs 🟢 MESHLET_CULLING_PASS
meshlet_raster_clusters # 0 9 <storage, read_write> array<u32> 🟢 MESHLET_CULLING_PASS
depth_pyramid # 0 10 texture_2d<f32> 🟢 MESHLET_CULLING_PASS
view # 0 11 <uniform> View 🟢 MESHLET_CULLING_PASS
previous_view # 0 12 <uniform> PreviousViewUniforms 🟢 MESHLET_CULLING_PASS
meshlet_cluster_meshlet_ids # 0 0 <storage, read> array<u32> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlets # 0 1 <storage, read> array<Meshlet> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_indices # 0 2 <storage, read> array<u32> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_vertex_positions # 0 3 <storage, read> array<u32> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_cluster_instance_ids # 0 4 <storage, read> array<u32> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_instance_uniforms # 0 5 <storage, read> array<Mesh> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_raster_clusters # 0 6 <storage, read> array<u32> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_software_raster_cluster_count # 0 7 <storage, read> u32 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_visibility_buffer # 0 8 <storage, read_write> array<atomic<u64>> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS, 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
meshlet_visibility_buffer # 0 8 <storage, read_write> array<atomic<u32>> 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS, 🔴 MESHLET_VISIBILITY_BUFFER_RASTER_PASS_OUTPUT
view # 0 9 <uniform> View 🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS
meshlet_visibility_buffer # 1 0 <storage, read> array<u64> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_cluster_meshlet_ids # 1 1 <storage, read> array<u32> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlets # 1 2 <storage, read> array<Meshlet> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_indices # 1 3 <storage, read> array<u32> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_vertex_positions # 1 4 <storage, read> array<u32> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_vertex_normals # 1 5 <storage, read> array<u32> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_vertex_uvs # 1 6 <storage, read> array<vec2<f32>> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_cluster_instance_ids # 1 7 <storage, read> array<u32> 🟢 MESHLET_MESH_MATERIAL_PASS
meshlet_instance_uniforms # 1 8 <storage, read> array<Mesh> 🟢 MESHLET_MESH_MATERIAL_PASS

Structures

Meshlet

#
Name Type
start_vertex_position_bit u32
start_vertex_attribute_id u32
start_index_id u32
packed_a u32
packed_b u32
min_vertex_position_channel_x f32
min_vertex_position_channel_y f32
min_vertex_position_channel_z f32

MeshletBoundingSpheres

#
Name Type
culling_sphere MeshletBoundingSphere
lod_group_sphere MeshletBoundingSphere
lod_parent_group_sphere MeshletBoundingSphere

MeshletBoundingSphere

#
Name Type
center vec3<f32>
radius f32

DispatchIndirectArgs

#
Name Type
x atomic<u32>
y u32
z u32

DrawIndirectArgs

#
Name Type
vertex_count u32
instance_count atomic<u32>
first_vertex u32
first_instance u32

Constants

#
Name Type Shader Def
scene_cluster_count u32 🟢 MESHLET_CULLING_PASS
meshlet_raster_cluster_rightmost_slot u32 🟢 MESHLET_CULLING_PASS

Functions

get_meshlet_vertex_count

#
fn get_meshlet_vertex_count(meshlet: ptr<function, Meshlet>) -> u32
Parameter Type
meshlet ptr<function, Meshlet>
Returns: u32

get_meshlet_triangle_count

#
fn get_meshlet_triangle_count(meshlet: ptr<function, Meshlet>) -> u32
Parameter Type
meshlet ptr<function, Meshlet>
Returns: u32

should_cull_instance

#

Shader defs:

🟢 MESHLET_CULLING_PASS

fn should_cull_instance(instance_id: u32) -> bool
Parameter Type
instance_id u32
Returns: bool

cluster_is_second_pass_candidate

#

Shader defs:

🟢 MESHLET_CULLING_PASS

TODO: Load 4x per workgroup instead of once per thread?
fn cluster_is_second_pass_candidate(cluster_id: u32) -> bool
Parameter Type
cluster_id u32
Returns: bool

get_meshlet_vertex_id

#

Shader defs:

🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS

TODO: Load only twice, instead of 3x in cases where you load 3 indices per thread?
fn get_meshlet_vertex_id(index_id: u32) -> u32
Parameter Type
index_id u32
Returns: u32

get_meshlet_vertex_position

#

Shader defs:

🟢 MESHLET_VISIBILITY_BUFFER_RASTER_PASS

fn get_meshlet_vertex_position(meshlet: ptr<function, Meshlet>, vertex_id: u32) -> vec3<f32>
Parameter Type
meshlet ptr<function, Meshlet>
vertex_id u32
Returns: vec3<f32>

get_meshlet_vertex_id

#

Shader defs:

🟢 MESHLET_MESH_MATERIAL_PASS

TODO: Load only twice, instead of 3x in cases where you load 3 indices per thread?
fn get_meshlet_vertex_id(index_id: u32) -> u32
Parameter Type
index_id u32
Returns: u32

get_meshlet_vertex_position

#

Shader defs:

🟢 MESHLET_MESH_MATERIAL_PASS

fn get_meshlet_vertex_position(meshlet: ptr<function, Meshlet>, vertex_id: u32) -> vec3<f32>
Parameter Type
meshlet ptr<function, Meshlet>
vertex_id u32
Returns: vec3<f32>

get_meshlet_vertex_normal

#

Shader defs:

🟢 MESHLET_MESH_MATERIAL_PASS

fn get_meshlet_vertex_normal(meshlet: ptr<function, Meshlet>, vertex_id: u32) -> vec3<f32>
Parameter Type
meshlet ptr<function, Meshlet>
vertex_id u32
Returns: vec3<f32>

get_meshlet_vertex_uv

#

Shader defs:

🟢 MESHLET_MESH_MATERIAL_PASS

fn get_meshlet_vertex_uv(meshlet: ptr<function, Meshlet>, vertex_id: u32) -> vec2<f32>
Parameter Type
meshlet ptr<function, Meshlet>
vertex_id u32
Returns: vec2<f32>