From ab2d7e3150eb28f9a8fc4ce83c6477753bdbcee3 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 14 Aug 2026 00:59:05 -0700 Subject: pixel pipeline working --- src/shader.wgsl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/shader.wgsl (limited to 'src/shader.wgsl') 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; + +struct VertexOutput { + @builtin(position) clip_position: vec4, + @location(0) uv: vec2, +}; + +@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 { + 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 -- cgit v1.3.1