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.
1struct Globals {
2 mvp: mat4x4<f32>,
3 size: vec2<f32>,
4 _pad0: u32,
5 _pad1: u32,
6};
8struct Locals {
9 position: vec2<f32>,
10 velocity: vec2<f32>,
11 color: u32,
12 _pad0: u32,
13 _pad1: u32,
14 _pad2: u32,
15};
17@group(0)
18@binding(0)
19var<uniform> globals: Globals;
21@group(1)
22@binding(0)
23var<uniform> locals: Locals;
25struct VertexOutput {
26 @builtin(position) position: vec4<f32>,
27 @location(0) tex_coords: vec2<f32>,
28 @location(1) color: vec4<f32>,
29};
31@vertex
32fn vs_main(@builtin(vertex_index) vi: u32) -> VertexOutput {
33 let tc = vec2<f32>(f32(vi & 1u), 0.5 * f32(vi & 2u));
34 let offset = vec2<f32>(tc.x * globals.size.x, tc.y * globals.size.y);
35 let pos = globals.mvp * vec4<f32>(locals.position + offset, 0.0, 1.0);
36 let color = vec4<f32>((vec4<u32>(locals.color) >> vec4<u32>(0u, 8u, 16u, 24u)) & vec4<u32>(255u)) / 255.0;
37 return VertexOutput(pos, tc, color);
40@group(0)
41@binding(1)
42var tex: texture_2d<f32>;
43@group(0)
44@binding(2)
45var sam: sampler;
47@fragment
48fn fs_main(vertex: VertexOutput) -> @location(0) vec4<f32> {
49 return vertex.color * textureSampleLevel(tex, sam, vertex.tex_coords, 0.0);
Contents