1struct Mesh {2 /// Affine 4x3 matrices transposed to 3x43 /// Use bevy_render::maths::affine3_to_square to unpack4 world_from_local: mat3x4<f32>,5 previous_world_from_local: mat3x4<f32>,6 /// 3x3 matrix packed in mat2x4 and f32 as:7 /// [0].xyz, [1].x,8 /// [1].yz, [2].xy9 /// [2].z10 /// Use package::render::mesh_functions::mat2x4_f32_to_mat3x3_unpack to unpack11 local_from_world_transpose_a: mat2x4<f32>,12 local_from_world_transpose_b: f32,13 /// 'flags' is a bit field indicating various options. u32 is 32 bits so we have up to 32 options.14 flags: u32,15 lightmap_uv_rect: vec2<u32>,16 /// The index of the mesh's first vertex in the vertex buffer.17 first_vertex_index: u32,18 current_skin_index: u32,19 /// Low 16 bits: index of the material inside the bind group data.20 /// High 16 bits: index of the lightmap in the binding array.21 material_and_lightmap_bind_group_slot: u32,22 /// User supplied index to identify the mesh instance23 tag: u32,24 morph_descriptor_index: u32,25 /// The index of the mesh metadata buffer.26 metadata_index: u32,27};29@if(SKINNED)30struct SkinnedMesh {31 data: array<mat4x4<f32>, 256u>,32};34@if(MORPH_TARGETS)35struct MorphWeights {36 weights: array<vec4<f32>, 64u>, // 64 = 256 / 4 (256 = MAX_MORPH_WEIGHTS)37};39/// Describes a single mesh instance that uses morph targets.40@if(MORPH_TARGETS)41struct MorphDescriptor {42 /// The index of the first morph target weight in the `morph_weights` array.43 current_weights_offset: u32,44 /// The index of the first morph target weight in the `prev_morph_weights`45 /// array.46 prev_weights_offset: u32,47 /// The index of the first morph target for this mesh in the48 /// `MorphAttributes` array.49 targets_offset: u32,50 /// The number of vertices in the mesh.51 vertex_count: u32,52 /// The number of morph targets this mesh has.53 weight_count: u32,54};56/// Morph displacement for a single vertex.57@if(MORPH_TARGETS)58struct MorphAttributes {59 /// The position delta.60 position: vec3<f32>,61 /// Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.62 pad_a: f32,63 /// The normal delta.64 normal: vec3<f32>,65 /// Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.66 pad_b: f32,67 /// The tangent delta.68 tangent: vec3<f32>,69 /// Padding, to ensure that each `vec3<f32>` is aligned to 16 bytes.70 pad_c: f32,71};73// [2^0, 2^16)74const MESH_FLAGS_VISIBILITY_RANGE_INDEX_BITS: u32 = (1u << 16u) - 1u;75const MESH_FLAGS_AABB_BASED_VISIBILITY_RANGE_BIT: u32 = 1u << 27u;76const MESH_FLAGS_NO_FRUSTUM_CULLING_BIT: u32 = 1u << 28u;77const MESH_FLAGS_SHADOW_RECEIVER_BIT: u32 = 1u << 29u;78const MESH_FLAGS_TRANSMITTED_SHADOW_RECEIVER_BIT: u32 = 1u << 30u;79// if the flag is set, the sign is positive, else it is negative80const MESH_FLAGS_SIGN_DETERMINANT_MODEL_3X3_BIT: u32 = 1u << 31u;