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#import bevy_pbr::mesh_view_bindings
2#import bevy_pbr::mesh_bindings
4// NOTE: Bindings must come before functions that use them!
5#import bevy_pbr::mesh_functions
7struct Vertex {
8 @location(0) position: vec3<f32>,
9 @location(1) normal: vec3<f32>,
10#ifdef VERTEX_UVS
11 @location(2) uv: vec2<f32>,
12#endif
13#ifdef VERTEX_TANGENTS
14 @location(3) tangent: vec4<f32>,
15#endif
16#ifdef VERTEX_COLORS
17 @location(4) color: vec4<f32>,
18#endif
19#ifdef SKINNED
20 @location(5) joint_indices: vec4<u32>,
21 @location(6) joint_weights: vec4<f32>,
22#endif
23};
25struct VertexOutput {
26 @builtin(position) clip_position: vec4<f32>,
27 #import bevy_pbr::mesh_vertex_output
28};
30@vertex
31fn vertex(vertex: Vertex) -> VertexOutput {
32 var out: VertexOutput;
33#ifdef SKINNED
34 var model = skin_model(vertex.joint_indices, vertex.joint_weights);
35 out.world_normal = skin_normals(model, vertex.normal);
36#else
37 var model = mesh.model;
38 out.world_normal = mesh_normal_local_to_world(vertex.normal);
39#endif
40 out.world_position = mesh_position_local_to_world(model, vec4<f32>(vertex.position, 1.0));
41#ifdef VERTEX_UVS
42 out.uv = vertex.uv;
43#endif
44#ifdef VERTEX_TANGENTS
45 out.world_tangent = mesh_tangent_local_to_world(model, vertex.tangent);
46#endif
47#ifdef VERTEX_COLORS
48 out.color = vertex.color;
49#endif
51 out.clip_position = mesh_position_world_to_clip(out.world_position);
52 return out;
55struct FragmentInput {
56 @builtin(front_facing) is_front: bool,
57 #import bevy_pbr::mesh_vertex_output
58};
60@fragment
61fn fragment(in: FragmentInput) -> @location(0) vec4<f32> {
62#ifdef VERTEX_COLORS
63 return in.color;
64#else
65 return vec4<f32>(1.0, 0.0, 1.0, 1.0);
66#endif
Contents