Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_pbr::mesh_functions
3fn mesh_position_local_to_world(model: mat4x4<f32>, vertex_position: vec4<f32>) -> vec4<f32> {
4 return model * vertex_position;
5}
7fn mesh_position_world_to_clip(world_position: vec4<f32>) -> vec4<f32> {
8 return view.view_proj * world_position;
9}
11// NOTE: The intermediate world_position assignment is important
12// for precision purposes when using the 'equals' depth comparison
13// function.
14fn mesh_position_local_to_clip(model: mat4x4<f32>, vertex_position: vec4<f32>) -> vec4<f32> {
15 let world_position = mesh_position_local_to_world(model, vertex_position);
16 return mesh_position_world_to_clip(world_position);
19fn mesh_normal_local_to_world(vertex_normal: vec3<f32>) -> vec3<f32> {
20 return mat3x3<f32>(
21 mesh.inverse_transpose_model[0].xyz,
22 mesh.inverse_transpose_model[1].xyz,
23 mesh.inverse_transpose_model[2].xyz
24 ) * vertex_normal;
27fn mesh_tangent_local_to_world(model: mat4x4<f32>, vertex_tangent: vec4<f32>) -> vec4<f32> {
28 return vec4<f32>(
29 mat3x3<f32>(
30 model[0].xyz,
31 model[1].xyz,
32 model[2].xyz
33 ) * vertex_tangent.xyz,
34 vertex_tangent.w
35 );
Contents