From 14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Thu, 21 May 2026 07:58:47 -0400 Subject: tacmap back as canvas. begin work on fleet scheduling --- assets/shaders/canvas.wgsl | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 assets/shaders/canvas.wgsl (limited to 'assets/shaders/canvas.wgsl') diff --git a/assets/shaders/canvas.wgsl b/assets/shaders/canvas.wgsl new file mode 100644 index 0000000..0aa61b1 --- /dev/null +++ b/assets/shaders/canvas.wgsl @@ -0,0 +1,51 @@ +struct VertexOutput { + @builtin(position) clip_position: vec4, + @location(0) uv: vec2 +} + +const QUAD_VERTICES = array,4>( + vec2(0.0, 0.0), + vec2(2.0, 0.0), + vec2(0.0, 2.0), + vec2(2.0, 2.0), +); + +const QUAD_UVS = array,4>( + vec2(0.0, 1.0), + vec2(1.0, 1.0), + vec2(0.0, 0.0), + vec2(1.0, 0.0), +); + +@group(0) @binding(0) +var canvas_texture: texture_2d; +@group(0) @binding(1) +var canvas_sampler: sampler; + +@group(1) @binding(0) +var rect: vec4; + +@vertex +fn vs_main( + @builtin(vertex_index) index: u32, +) -> VertexOutput { + var out: VertexOutput; + + let model = QUAD_VERTICES[index]; + + out.uv = QUAD_UVS[index]; + out.clip_position = vec4( + -1.0 + (model.x * rect.z), + -1.0 + (model.y * rect.w), + 0.0, + 1.0); + + return out; +} + +@fragment +fn fs_main(in: VertexOutput) +-> @location(0) vec4 +{ + return textureSample(canvas_texture, canvas_sampler, in.uv); +} -- cgit v1.2.3