1import package::mesh2d::{ 3 bindings::{mesh, metadata}, 5import bevy_render::mesh::metadata_types::MeshMetadata; 6import bevy_render::maths::{affine3_to_square, mat2x4_f32_to_mat3x3_unpack}; 8fn get_world_from_local(instance_index: u32) -> mat4x4<f32> { 9 return affine3_to_square(mesh[instance_index].world_from_local); 12fn mesh2d_position_local_to_world(world_from_local: mat4x4<f32>, vertex_position: vec4<f32>) -> vec4<f32> { 13 return world_from_local * vertex_position; 16fn mesh2d_position_world_to_clip(world_position: vec4<f32>) -> vec4<f32> { 17 return view.clip_from_world * world_position; 23fn mesh2d_position_local_to_clip(world_from_local: mat4x4<f32>, vertex_position: vec4<f32>) -> vec4<f32> { 24 let world_position = mesh2d_position_local_to_world(world_from_local, vertex_position); 25 return mesh2d_position_world_to_clip(world_position); 28fn mesh2d_normal_local_to_world(vertex_normal: vec3<f32>, instance_index: u32) -> vec3<f32> { 29 return mat2x4_f32_to_mat3x3_unpack( 30 mesh[instance_index].local_from_world_transpose_a, 31 mesh[instance_index].local_from_world_transpose_b, 35fn mesh2d_tangent_local_to_world(world_from_local: mat4x4<f32>, vertex_tangent: vec4<f32>) -> vec4<f32> { 38 world_from_local[0].xyz, 39 world_from_local[1].xyz, 40 world_from_local[2].xyz 41 ) * vertex_tangent.xyz, 46fn get_tag(instance_index: u32) -> u32 { 47 return mesh[instance_index].tag; 50fn get_metadata(instance_index: u32) -> MeshMetadata { 51@if(METADATA_USE_UNIFORM_BUFFERS) 54 return metadata[mesh[instance_index].metadata_index];