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_functions::{get_world_from_local, mesh_position_local_to_clip}
3struct Vertex {
4 @location(0) position: vec3<f32>,
5 @location(1) normal: vec3<f32>,
6 @location(2) uv: vec2<f32>,
8 @location(3) i_pos_scale: vec4<f32>,
9 @location(4) i_color: vec4<f32>,
10};
12struct VertexOutput {
13 @builtin(position) clip_position: vec4<f32>,
14 @location(0) color: vec4<f32>,
15};
17@vertex
18fn vertex(vertex: Vertex) -> VertexOutput {
19 let position = vertex.position * vertex.i_pos_scale.w + vertex.i_pos_scale.xyz;
20 var out: VertexOutput;
21 // NOTE: Passing 0 as the instance_index to get_world_from_local() is a hack
22 // for this example as the instance_index builtin would map to the wrong
23 // index in the Mesh array. This index could be passed in via another
24 // uniform instead but it's unnecessary for the example.
25 out.clip_position = mesh_position_local_to_clip(
26 get_world_from_local(0u),
27 vec4<f32>(position, 1.0)
28 );
29 out.color = vertex.i_color;
30 return out;
33@fragment
34fn fragment(in: VertexOutput) -> @location(0) vec4<f32> {
35 return in.color;
Contents