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 VertexOutput {
2 @builtin(position) position: vec4<f32>,
3 @location(0) tex_coords: vec2<f32>,
4}
6@vertex
7fn vs_main(@builtin(vertex_index) vi: u32) -> VertexOutput {
8 var out: VertexOutput;
10 out.tex_coords = vec2<f32>(
11 f32((vi << 1u) & 2u),
12 f32(vi & 2u),
13 );
15 out.position = vec4<f32>(out.tex_coords * 2.0 - 1.0, 0.0, 1.0);
17 // Invert y so the texture is not upside down
18 out.tex_coords.y = 1.0 - out.tex_coords.y;
19 return out;
22@group(0) @binding(0)
23var texture: texture_2d<f32>;
24@group(0) @binding(1)
25var texture_sampler: sampler;
27@fragment
28fn fs_main(vs: VertexOutput) -> @location(0) vec4<f32> {
29 return textureSample(texture, texture_sampler, vs.tex_coords);
Contents