From d9f10d25d0f420aeae189370662d34ca9027f763 Mon Sep 17 00:00:00 2001 From: praschke Date: Mon, 22 Aug 2022 13:30:14 +0000 Subject: [PATCH] shaderexp: use one triangle for fullscreen --- shaderexp/main.zig | 2 +- shaderexp/vert.wgsl | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/shaderexp/main.zig b/shaderexp/main.zig index f055fb3f..a45a8a78 100755 --- a/shaderexp/main.zig +++ b/shaderexp/main.zig @@ -139,7 +139,7 @@ pub fn update(app: *App, core: *mach.Core) !void { const pass = encoder.beginRenderPass(&render_pass_info); pass.setPipeline(app.pipeline); pass.setBindGroup(0, app.bind_group, &.{0}); - pass.draw(6, 1, 0, 0); + pass.draw(3, 1, 0, 0); pass.end(); pass.release(); diff --git a/shaderexp/vert.wgsl b/shaderexp/vert.wgsl index bce7ec2e..6f972316 100755 --- a/shaderexp/vert.wgsl +++ b/shaderexp/vert.wgsl @@ -1,29 +1,23 @@ struct VertexOut { - @builtin(position) position_clip : vec4, - @location(0) frag_uv : vec2, + @builtin(position) position_clip : vec4, + @location(0) frag_uv : vec2, } @vertex fn main(@builtin(vertex_index) index : u32) -> VertexOut { - var pos = array, 6>( - vec2(-1.0, -1.0), - vec2( 1.0, -1.0), - vec2( 1.0, 1.0), - vec2( 1.0, 1.0), - vec2(-1.0, 1.0), - vec2(-1.0, -1.0) + var pos = array, 3>( + vec2(-1.0, -1.0), + vec2( 3.0, -1.0), + vec2(-1.0, 3.0), ); - var uv = array, 6>( - vec2(0.0, 0.0), - vec2(1.0, 0.0), - vec2(1.0, 1.0), - vec2(1.0, 1.0), - vec2(0.0, 1.0), - vec2(0.0, 0.0) + var uv = array, 3>( + vec2(0.0, 0.0), + vec2(2.0, 0.0), + vec2(0.0, 2.0), ); - var output : VertexOut; - output.position_clip = vec4(pos[index], 0.0, 1.0); - output.frag_uv = uv[index]; - return output; + var output : VertexOut; + output.position_clip = vec4(pos[index], 0.0, 1.0); + output.frag_uv = uv[index]; + return output; }