1import package::render::{ 5 morph::{morph_position, morph_normal, morph_tangent}, 6 forward_io::{Vertex, UncompressedVertex, VertexOutput, decompress_vertex}, 7 view_transformations::position_world_to_clip, 13fn morph_vertex(vertex_in: UncompressedVertex, instance_index: u32) -> UncompressedVertex { 14 var vertex = vertex_in; 15 let first_vertex = mesh[instance_index].first_vertex_index; 16 let vertex_index = vertex.index - first_vertex; 17 let morph_descriptor_index = mesh[instance_index].morph_descriptor_index; 19 let weight_count = package::render::morph::layer_count(morph_descriptor_index); 20 for (var i: u32 = 0u; i < weight_count; i ++) { 21 let weight = package::render::morph::weight_at(i, morph_descriptor_index); 25 vertex.position += weight * morph_position(vertex_index, i, morph_descriptor_index); 27 vertex.normal += weight * morph_normal(vertex_index, i, morph_descriptor_index); 29 vertex.tangent += vec4(weight * morph_tangent(vertex_index, i, morph_descriptor_index), 0.0); 35fn vertex(vertex_no_morph: Vertex) -> VertexOutput { 36 var out: VertexOutput; 37 let uncompressed_vertex_no_morph = decompress_vertex(vertex_no_morph, vertex_no_morph.instance_index); 39 var vertex = morph_vertex(uncompressed_vertex_no_morph, vertex_no_morph.instance_index); 41 var vertex = uncompressed_vertex_no_morph; 43 let mesh_world_from_local = mesh_functions::get_world_from_local(vertex_no_morph.instance_index); 48 var world_from_local = skinning::skin_model( 51 vertex_no_morph.instance_index 54 var world_from_local = mesh_world_from_local; 56@if(VERTEX_NORMALS && SKINNED) 57 out.world_normal = skinning::skin_normals(world_from_local, vertex.normal); 58@if(VERTEX_NORMALS && !SKINNED) 59 out.world_normal = mesh_functions::mesh_normal_local_to_world( 63 vertex_no_morph.instance_index 67 out.world_position = mesh_functions::mesh_position_local_to_world(world_from_local, vec4<f32>(vertex.position, 1.0)); 69 out.position = position_world_to_clip(out.world_position.xyz); 74 out.uv_b = vertex.uv_b; 77 out.world_tangent = mesh_functions::mesh_tangent_local_to_world( 82 vertex_no_morph.instance_index 86 out.color = vertex.color; 88@if(VERTEX_OUTPUT_INSTANCE_INDEX) 91 out.instance_index = vertex_no_morph.instance_index; 93@if(VISIBILITY_RANGE_DITHER) 94 out.visibility_range_dither = mesh_functions::get_visibility_range_dither_level( 95 vertex_no_morph.instance_index, mesh_world_from_local[3]); 103) -> @location(0) vec4<f32> { 107 return vec4<f32>(1.0, 0.0, 1.0, 1.0);