diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-21 07:58:47 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-21 07:58:47 -0400 |
| commit | 14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9 (patch) | |
| tree | 6c4864880bc54778122f1c0e4fa195c16cc064db /assets | |
| parent | a0a3b3974cab754c10a1517d82762b99482970ce (diff) | |
| download | systemic4x-14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9.tar.gz systemic4x-14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9.tar.bz2 systemic4x-14ca7b5fc15eb2618b46bde0cac85e37ebc9ebd9.zip | |
tacmap back as canvas. begin work on fleet scheduling
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/shaders/canvas.wgsl | 51 |
1 files changed, 51 insertions, 0 deletions
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<f32>, + @location(0) uv: vec2<f32> +} + +const QUAD_VERTICES = array<vec2<f32>,4>( + vec2<f32>(0.0, 0.0), + vec2<f32>(2.0, 0.0), + vec2<f32>(0.0, 2.0), + vec2<f32>(2.0, 2.0), +); + +const QUAD_UVS = array<vec2<f32>,4>( + vec2<f32>(0.0, 1.0), + vec2<f32>(1.0, 1.0), + vec2<f32>(0.0, 0.0), + vec2<f32>(1.0, 0.0), +); + +@group(0) @binding(0) +var canvas_texture: texture_2d<f32>; +@group(0) @binding(1) +var canvas_sampler: sampler; + +@group(1) @binding(0) +var<uniform> rect: vec4<f32>; + +@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<f32>( + -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<f32> +{ + return textureSample(canvas_texture, canvas_sampler, in.uv); +} |
