struct VertexOutput {
@builtin(position) position: vec4<f32>,
@location(0) texcoord: vec2<f32>
}
@vertex fn vs(@builtin(vertex_index) vertexIndex: u32) -> VertexOutput {
let pos = array(
vec2<f32>(0.0, 0.0),
vec2<f32>(1.0, 0.0),
vec2<f32>(0.0, 1.0),
vec2<f32>(0.0, 1.0),
vec2<f32>(1.0, 0.0),
vec2<f32>(1.0, 1.0)
);
var out: VertexOutput;
let xy = pos[vertexIndex];
out.position = vec4<f32>(xy * 2.0 - 1.0, 0.0, 1.0);
out.texcoord = vec2<f32>(xy.x, 1.0 - xy.y);
return out;
}
@group(0) @binding(0) var texSampler: sampler;
@group(0) @binding(1) var tex: texture_2d<f32>;
@fragment fn fs(inp: VertexOutput) -> @location(0) vec4<f32> {
return textureSample(tex, texSampler, inp.texcoord);
}