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// This vertex shader will create a triangle that will cover the entire screen
2// with minimal effort, avoiding the need for a vertex buffer etc.
3@vertex
4fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> @builtin(position) vec4<f32> {
5 let x = f32((in_vertex_index & 1u) << 2u);
6 let y = f32((in_vertex_index & 2u) << 1u);
7 return vec4<f32>(x - 1.0, y - 1.0, 0.0, 1.0);
8}
10@group(0) @binding(0) var t: texture_2d<f32>;
12@fragment
13fn fs_main(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
14 let coords = floor(pos.xy);
15 return textureLoad(t, vec2<i32>(coords), 0i);
Contents