// Vertex shader @group(0) @binding(0) var t_diffuse: texture_2d; @group(0) @binding(1) var s_diffuse: sampler; struct VertexOutput { @builtin(position) clip_position: vec4, @location(0) uv: vec2, } @vertex fn vs_main(@builtin(vertex_index) in_vertex_index: u32) -> VertexOutput { // Generate a triangle to fill the screen. // The approach is based on: https://stackoverflow.com/a/59739538/4593433. var vertices = array( vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0) ); var out: VertexOutput; out.uv = vertices[in_vertex_index]; out.clip_position = vec4(out.uv, 0.0, 1.0); return out; } // Fragment shader @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { let uv = fma(in.uv, vec2(0.5), vec2(0.5)); let color = textureSample(t_diffuse, s_diffuse, uv).rgb; return vec4(color, 1.0); }