From 5ad6b4dc1c6e889b5258d4adc82cb06c524ac08b Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 8 Apr 2023 21:49:45 +0100 Subject: [PATCH] Add a simple texture color change compute shader --- assets/shaders/image_recolor.wgsl | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 assets/shaders/image_recolor.wgsl diff --git a/assets/shaders/image_recolor.wgsl b/assets/shaders/image_recolor.wgsl new file mode 100644 index 0000000..b01c614 --- /dev/null +++ b/assets/shaders/image_recolor.wgsl @@ -0,0 +1,12 @@ +@group(0) @binding(0) var output: texture_storage_2d; + +@compute @workgroup_size(8, 8, 1) +fn compute(@builtin(global_invocation_id) global_id: vec3) { + let img_coord = vec2(global_id.xy); + let img_dims = textureDimensions(output); + let img_coord_frac = vec2( + f32(img_coord.x) / f32(img_dims.x), + f32(img_coord.y) / f32(img_dims.y) + ); + textureStore(output, img_coord, vec4(img_coord_frac, 1.0, 1.0)); +} \ No newline at end of file