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_render::view::View
2#import bevy_enoki::particle_vertex_out::{ VertexOutput }
4@group(0) @binding(0) var<uniform> view: View;
6struct VertexIn {
7 @builtin(vertex_index) index: u32,
8 @location(0) i_transform: vec4<f32>,
9 @location(1) i_scale_lifetime: vec4<f32>,
10 @location(2) i_color: vec4<f32>,
11};
13@vertex
14fn vertex(in: VertexIn) -> VertexOutput {
15 var out: VertexOutput;
17 let vertex_position = vec3<f32>(
18 f32(in.index & 0x1u),
19 f32((in.index & 0x2u) >> 1u),
20 0.0
21 );
23 let local = vertex_position.xy - vec2(0.5, 0.5);
24 let scaled = local * in.i_scale_lifetime.xy;
25 let angle = in.i_transform.w;
26 let sine = sin(angle);
27 let cosine = cos(angle);
28 let rotated = vec2(
29 cosine * scaled.x - sine * scaled.y,
30 sine * scaled.x + cosine * scaled.y,
31 );
32 let world_position = vec3(in.i_transform.xy + rotated, in.i_transform.z);
34 out.clip_position = view.clip_from_world * vec4(world_position, 1.0);
36 out.color = in.i_color;
37 out.uv = vec2(vertex_position.x, 1.-vertex_position.y);
39 out.lifetime_frac = in.i_scale_lifetime.z;
40 out.lifetime_total = in.i_scale_lifetime.w;
42 return out;
Contents