1
- #import bevy_pbr ::mesh_bindings mesh
2
- #import bevy_pbr ::mesh_functions get_model_matrix , mesh_position_local_to_clip
3
- #import bevy_pbr ::morph
4
-
5
- #ifdef SKINNED
6
- #import bevy_pbr ::skinning
7
- #endif
8
-
9
- struct Vertex {
10
- @builtin (instance_index ) instance_index : u32 ,
11
- @location (0 ) position : vec3 <f32 >,
12
- #ifdef SKINNED
13
- @location (5 ) joint_indexes : vec4 <u32 >,
14
- @location (6 ) joint_weights : vec4 <f32 >,
15
- #endif
16
- #ifdef MORPH_TARGETS
17
- @builtin (vertex_index ) index : u32 ,
18
- #endif
19
- };
20
-
21
- struct VertexOutput {
22
- @builtin (position ) clip_position : vec4 <f32 >,
23
- };
24
-
25
-
26
- #ifdef MORPH_TARGETS
27
- fn morph_vertex (vertex_in : Vertex ) -> Vertex {
28
- var vertex = vertex_in ;
29
- let weight_count = bevy_pbr ::morph ::layer_count ();
30
- for (var i : u32 = 0u ; i < weight_count ; i ++ ) {
31
- let weight = bevy_pbr ::morph ::weight_at (i );
32
- if weight == 0.0 {
33
- continue ;
34
- }
35
- vertex . position += weight * bevy_pbr ::morph ::morph (vertex . index, bevy_pbr ::morph ::position_offset , i );
36
- }
37
- return vertex ;
38
- }
39
- #endif
40
-
41
- @vertex
42
- fn vertex (vertex_no_morph : Vertex ) -> VertexOutput {
43
-
44
- #ifdef MORPH_TARGETS
45
- var vertex = morph_vertex (vertex_no_morph );
46
- #else
47
- var vertex = vertex_no_morph ;
48
- #endif
49
-
50
- #ifdef SKINNED
51
- let model = bevy_pbr ::skinning ::skin_model (vertex . joint_indexes, vertex . joint_weights);
52
- #else
53
- let model = get_model_matrix (vertex . instance_index);
54
- #endif
55
-
56
- var out : VertexOutput ;
57
- out . clip_position = mesh_position_local_to_clip (model , vec4 <f32 >(vertex . position, 1.0 ));
58
- return out ;
59
- }
1
+ #import bevy_pbr ::mesh_vertex_output MeshVertexOutput
60
2
61
3
@fragment
62
- fn fragment () -> @location (0 ) vec4 <f32 > {
4
+ fn fragment (in : MeshVertexOutput ) -> @location (0 ) vec4 <f32 > {
63
5
return vec4 <f32 >(1.0 , 1.0 , 1.0 , 1.0 );
64
6
}
0 commit comments