From 1b0e1f4bce7e52d12c677a2f3234d87c732f881d Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Fri, 7 Apr 2023 19:31:38 +0100 Subject: [PATCH] Add basic vertex and fragment shader --- assets/shaders/shader.wgsl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 assets/shaders/shader.wgsl diff --git a/assets/shaders/shader.wgsl b/assets/shaders/shader.wgsl new file mode 100644 index 0000000..4b2f594 --- /dev/null +++ b/assets/shaders/shader.wgsl @@ -0,0 +1,19 @@ +struct VertexOutput { + @builtin(position) clip_position: vec4, +}; + +@vertex +fn vertex( + @builtin(vertex_index) in_vertex_index: u32, +) -> VertexOutput { + var out: VertexOutput; + let x = f32(1 - i32(in_vertex_index)) * 0.5; + let y = f32(i32(in_vertex_index & 1u) * 2 - 1) * 0.5; + out.clip_position = vec4(x, y, 0.0, 1.0); + return out; +} + +@fragment +fn fragment(in: VertexOutput) -> @location(0) vec4 { + return vec4(0.3, 0.2, 0.1, 1.0); +}