summaryrefslogtreecommitdiff
path: root/src/shader.wgsl
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-14 00:59:05 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-14 00:59:05 -0700
commitab2d7e3150eb28f9a8fc4ce83c6477753bdbcee3 (patch)
tree6407a935237b37f903101f7c00addd22920a8a0f /src/shader.wgsl
parentb0d9202a97d2843477c5abbaa491f298c70a55a3 (diff)
pixel pipeline working
Diffstat (limited to 'src/shader.wgsl')
-rw-r--r--src/shader.wgsl25
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