Back home 🏡 WGSL Spec Bevy WGSL Functions

mesh_preprocess.wgsl

Bindings

Name Group Binding index Binding type Type Shader Def
current_input # 0 0 <storage> array<MeshInput>
previous_input # 0 1 <storage> array<MeshInput>
work_items # 0 2 <storage> array<PreprocessWorkItem>
output # 0 3 <storage, read_write> array<Mesh>
indirect_parameters # 0 4 <storage, read_write> array<IndirectParameters> 🟢 INDIRECT
mesh_culling_data # 0 5 <storage> array<MeshCullingData> 🟢 FRUSTUM_CULLING
view # 0 6 <uniform> View 🟢 FRUSTUM_CULLING

Structures

MeshInput

#
Per-frame data that the CPU supplies to the GPU.
Name Type
world_from_local mat3x4<f32>
lightmap_uv_rect vec2<u32>
flags u32
previous_input_index u32
first_vertex_index u32
pad_a u32
pad_b u32
pad_c u32

MeshCullingData

#
Information about each mesh instance needed to cull it on GPU. At the moment, this just consists of its axis-aligned bounding box (AABB).
Name Type
aabb_center vec4<f32>
aabb_half_extents vec4<f32>

PreprocessWorkItem

#
One invocation of this compute shader: i.e. one mesh instance in a view.
Name Type
input_index u32
output_index u32

IndirectParameters

#
The wgpu indirect parameters structure. This is a union of two structures. For more information, see the corresponding comment in gpu_preprocessing.rs.
Name Type
data0 u32
instance_count atomic<u32>
first_vertex u32
data1 u32
instance_index u32

Functions

view_frustum_intersects_obb

#

Shader defs:

🟢 FRUSTUM_CULLING

Returns true if the view frustum intersects an oriented bounding box (OBB). aabb_center.w should be 1.0.
fn view_frustum_intersects_obb(world_from_local: mat4x4<f32>, aabb_center: vec4<f32>, aabb_half_extents: vec3<f32>) -> bool
Parameter Type
world_from_local mat4x4<f32>
aabb_center vec4<f32>
aabb_half_extents vec3<f32>
Returns: bool

main

#
@compute
fn main(global_invocation_id: vec3<u32>)
Parameter Type
global_invocation_id vec3<u32>