5 morph::{morph_position, morph_normal, morph_tangent}, 6 forward_io::{Vertex, VertexOutput}, 7 view_transformations::position_world_to_clip, 13fn morph_vertex(vertex_in: Vertex, instance_index: u32) -> Vertex { 14 var vertex = vertex_in; 15 let first_vertex = mesh[instance_index].first_vertex_index; 16 let vertex_index = vertex.index - first_vertex; 18 let weight_count = bevy_pbr::morph::layer_count(instance_index); 19 for (var i: u32 = 0u; i < weight_count; i ++) { 20 let weight = bevy_pbr::morph::weight_at(i, instance_index); 24 vertex.position += weight * morph_position(vertex_index, i, instance_index); 26 vertex.normal += weight * morph_normal(vertex_index, i, instance_index); 29 vertex.tangent += vec4(weight * morph_tangent(vertex_index, i, instance_index), 0.0); 37fn vertex(vertex_no_morph: Vertex) -> VertexOutput { 38 var out: VertexOutput; 41 var vertex = morph_vertex(vertex_no_morph, vertex_no_morph.instance_index); 43 var vertex = vertex_no_morph; 46 let mesh_world_from_local = mesh_functions::get_world_from_local(vertex_no_morph.instance_index); 51 var world_from_local = skinning::skin_model( 54 vertex_no_morph.instance_index 57 var world_from_local = mesh_world_from_local; 62 out.world_normal = skinning::skin_normals(world_from_local, vertex.normal); 64 out.world_normal = mesh_functions::mesh_normal_local_to_world( 68 vertex_no_morph.instance_index 73#ifdef VERTEX_POSITIONS 74 out.world_position = mesh_functions::mesh_position_local_to_world(world_from_local, vec4<f32>(vertex.position, 1.0)); 75 out.position = position_world_to_clip(out.world_position.xyz); 82 out.uv_b = vertex.uv_b; 86 out.world_tangent = mesh_functions::mesh_tangent_local_to_world( 91 vertex_no_morph.instance_index 96 out.color = vertex.color; 99#ifdef VERTEX_OUTPUT_INSTANCE_INDEX 102 out.instance_index = vertex_no_morph.instance_index; 105#ifdef VISIBILITY_RANGE_DITHER 106 out.visibility_range_dither = mesh_functions::get_visibility_range_dither_level( 107 vertex_no_morph.instance_index, mesh_world_from_local[3]); 116) -> @location(0) vec4<f32> { 120 return vec4<f32>(1.0, 0.0, 1.0, 1.0);