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_sprite::{
2 mesh2d_view_bindings::globals,
3 mesh2d_functions::{get_world_from_local, mesh2d_position_local_to_clip},
4}
6struct Vertex {
7 @builtin(instance_index) instance_index: u32,
8 @location(0) position: vec3<f32>,
9 @location(1) color: vec4<f32>,
10 @location(2) barycentric: vec3<f32>,
11};
13struct VertexOutput {
14 @builtin(position) clip_position: vec4<f32>,
15 @location(0) color: vec4<f32>,
16 @location(1) barycentric: vec3<f32>,
17};
19@vertex
20fn vertex(vertex: Vertex) -> VertexOutput {
21 var out: VertexOutput;
22 let world_from_local = get_world_from_local(vertex.instance_index);
23 out.clip_position = mesh2d_position_local_to_clip(world_from_local, vec4<f32>(vertex.position, 1.0));
24 out.color = vertex.color;
25 out.barycentric = vertex.barycentric;
26 return out;
29struct FragmentInput {
30 @location(0) color: vec4<f32>,
31 @location(1) barycentric: vec3<f32>,
32};
34@fragment
35fn fragment(input: FragmentInput) -> @location(0) vec4<f32> {
36 let d = min(input.barycentric.x, min(input.barycentric.y, input.barycentric.z));
37 let t = 0.05 * (0.85 + sin(5.0 * globals.time));
38 return mix(vec4(1.0,1.0,1.0,1.0), input.color, smoothstep(t, t+0.01, d));
Contents