diff options
Diffstat (limited to 'src/shader.wgsl')
| -rw-r--r-- | src/shader.wgsl | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/shader.wgsl b/src/shader.wgsl new file mode 100644 index 0000000..e545dac --- /dev/null +++ b/src/shader.wgsl @@ -0,0 +1,25 @@ +@group(0) @binding(0) var tex: texture_2d<f32>; + +struct VertexOutput { + @builtin(position) clip_position: vec4<f32>, + @location(0) uv: vec2<f32>, +}; + +@vertex +fn vs_main( + @builtin(vertex_index) i: u32, +) -> VertexOutput { + var out: VertexOutput; + let uv = vec2f(f32((i << 1u) & 2u), f32(i & 2u)); + out.clip_position = vec4f(uv.x * 2.0 - 1.0, 1.0 - uv.y * 2.0, 0.0, 1.0); + out.uv = uv; + + return out; +} + +@fragment +fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { + let dims = vec2f(textureDimensions(tex)); + return textureLoad(tex, vec2i(in.uv * dims), 0); + // return vec4f(0.0, 1.0, 0.0, 1.0); +}
\ No newline at end of file |
