#define_import_path bevy_sprite::mesh2d_functions fn mesh2d_position_local_to_world(model: mat4x4, vertex_position: vec4) -> vec4 { return model * vertex_position; } fn mesh2d_position_world_to_clip(world_position: vec4) -> vec4 { return view.view_proj * world_position; } // NOTE: The intermediate world_position assignment is important // for precision purposes when using the 'equals' depth comparison // function. fn mesh2d_position_local_to_clip(model: mat4x4, vertex_position: vec4) -> vec4 { let world_position = mesh2d_position_local_to_world(model, vertex_position); return mesh2d_position_world_to_clip(world_position); } fn mesh2d_normal_local_to_world(vertex_normal: vec3) -> vec3 { return mat3x3( mesh.inverse_transpose_model[0].xyz, mesh.inverse_transpose_model[1].xyz, mesh.inverse_transpose_model[2].xyz ) * vertex_normal; } fn mesh2d_tangent_local_to_world(model: mat4x4, vertex_tangent: vec4) -> vec4 { return vec4( mat3x3( model[0].xyz, model[1].xyz, model[2].xyz ) * vertex_tangent.xyz, vertex_tangent.w ); }