diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-28 09:08:57 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-28 09:08:57 +0100 |
| commit | 9ee410594a52cbc699b13de2bde4860d70c959a3 (patch) | |
| tree | d56adf5931d488abcf3ac8e24a828d2d5b02e8cc /common/shaders/compute | |
| parent | 6599a428cd69be6c66c5179e1f0fce42f561f935 (diff) | |
refactor: move common/shaders/ to src/shaders/
Relocates shared WGSL shaders under src/ where all source code lives,
eliminating the top-level common/ directory.
- Update asset references in workspaces/main/assets.txt and workspaces/test/assets.txt
- Update docs: PROJECT_CONTEXT.md, ARCHITECTURE.md, WORKSPACE_SYSTEM.md, SHADER_REUSE_INVESTIGATION.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'common/shaders/compute')
| -rw-r--r-- | common/shaders/compute/gen_blend.wgsl | 29 | ||||
| -rw-r--r-- | common/shaders/compute/gen_grid.wgsl | 24 | ||||
| -rw-r--r-- | common/shaders/compute/gen_mask.wgsl | 27 | ||||
| -rw-r--r-- | common/shaders/compute/gen_noise.wgsl | 26 | ||||
| -rw-r--r-- | common/shaders/compute/gen_perlin.wgsl | 44 |
5 files changed, 0 insertions, 150 deletions
diff --git a/common/shaders/compute/gen_blend.wgsl b/common/shaders/compute/gen_blend.wgsl deleted file mode 100644 index c6be7bb..0000000 --- a/common/shaders/compute/gen_blend.wgsl +++ /dev/null @@ -1,29 +0,0 @@ -// This file is part of the 64k demo project. -// GPU composite shader: Blend two textures. - -struct BlendParams { - width: u32, - height: u32, - blend_factor: f32, - _pad0: f32, -} - -@group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>; -@group(0) @binding(1) var<uniform> params: BlendParams; -@group(0) @binding(2) var input_a: texture_2d<f32>; -@group(0) @binding(3) var input_b: texture_2d<f32>; -@group(0) @binding(4) var tex_sampler: sampler; - -@compute @workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - if (id.x >= params.width || id.y >= params.height) { return; } - - let uv = vec2f(f32(id.x) / f32(params.width), - f32(id.y) / f32(params.height)); - - let color_a = textureSampleLevel(input_a, tex_sampler, uv, 0.0); - let color_b = textureSampleLevel(input_b, tex_sampler, uv, 0.0); - let blended = mix(color_a, color_b, params.blend_factor); - - textureStore(output_tex, id.xy, blended); -} diff --git a/common/shaders/compute/gen_grid.wgsl b/common/shaders/compute/gen_grid.wgsl deleted file mode 100644 index 4ce7ea3..0000000 --- a/common/shaders/compute/gen_grid.wgsl +++ /dev/null @@ -1,24 +0,0 @@ -// GPU procedural grid pattern generator. -// Simple grid lines with configurable spacing and thickness. - -struct GridParams { - width: u32, - height: u32, - grid_size: u32, - thickness: u32, -} - -@group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>; -@group(0) @binding(1) var<uniform> params: GridParams; - -@compute @workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - if (id.x >= params.width || id.y >= params.height) { return; } - - let on_line = (id.x % params.grid_size) < params.thickness || - (id.y % params.grid_size) < params.thickness; - - let val = select(0.0, 1.0, on_line); - - textureStore(output_tex, id.xy, vec4f(val, val, val, 1.0)); -} diff --git a/common/shaders/compute/gen_mask.wgsl b/common/shaders/compute/gen_mask.wgsl deleted file mode 100644 index 39f5b50..0000000 --- a/common/shaders/compute/gen_mask.wgsl +++ /dev/null @@ -1,27 +0,0 @@ -// This file is part of the 64k demo project. -// GPU composite shader: Multiply texture A by texture B (masking). - -struct MaskParams { - width: u32, - height: u32, -} - -@group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>; -@group(0) @binding(1) var<uniform> params: MaskParams; -@group(0) @binding(2) var input_a: texture_2d<f32>; -@group(0) @binding(3) var input_b: texture_2d<f32>; -@group(0) @binding(4) var tex_sampler: sampler; - -@compute @workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - if (id.x >= params.width || id.y >= params.height) { return; } - - let uv = vec2f(f32(id.x) / f32(params.width), - f32(id.y) / f32(params.height)); - - let color_a = textureSampleLevel(input_a, tex_sampler, uv, 0.0); - let mask_b = textureSampleLevel(input_b, tex_sampler, uv, 0.0); - let masked = color_a * mask_b; - - textureStore(output_tex, id.xy, masked); -} diff --git a/common/shaders/compute/gen_noise.wgsl b/common/shaders/compute/gen_noise.wgsl deleted file mode 100644 index 7b75f13..0000000 --- a/common/shaders/compute/gen_noise.wgsl +++ /dev/null @@ -1,26 +0,0 @@ -// GPU procedural noise texture generator. -// Uses compute shader for parallel texture generation. - -#include "math/noise" - -struct NoiseParams { - width: u32, - height: u32, - seed: f32, - frequency: f32, -} - -@group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>; -@group(0) @binding(1) var<uniform> params: NoiseParams; - -@compute @workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - if (id.x >= params.width || id.y >= params.height) { return; } - - let uv = vec2f(f32(id.x) / f32(params.width), - f32(id.y) / f32(params.height)); - let p = uv * params.frequency + params.seed; - let noise = noise_2d(p); - - textureStore(output_tex, id.xy, vec4f(noise, noise, noise, 1.0)); -} diff --git a/common/shaders/compute/gen_perlin.wgsl b/common/shaders/compute/gen_perlin.wgsl deleted file mode 100644 index 2807f6d..0000000 --- a/common/shaders/compute/gen_perlin.wgsl +++ /dev/null @@ -1,44 +0,0 @@ -// GPU procedural Perlin noise texture generator. -// Fractional Brownian Motion using value noise. - -#include "math/noise" - -struct PerlinParams { - width: u32, - height: u32, - seed: f32, - frequency: f32, - amplitude: f32, - amplitude_decay: f32, - octaves: u32, - _pad0: f32, // Padding for alignment -} - -@group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>; -@group(0) @binding(1) var<uniform> params: PerlinParams; - -@compute @workgroup_size(8, 8, 1) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - if (id.x >= params.width || id.y >= params.height) { return; } - - let uv = vec2f(f32(id.x) / f32(params.width), - f32(id.y) / f32(params.height)); - - var value = 0.0; - var amplitude = params.amplitude; - var frequency = params.frequency; - var total_amp = 0.0; - - for (var o: u32 = 0u; o < params.octaves; o++) { - let p = uv * frequency + params.seed; - value += noise_2d(p) * amplitude; - total_amp += amplitude; - frequency *= 2.0; - amplitude *= params.amplitude_decay; - } - - value /= total_amp; - let clamped = clamp(value, 0.0, 1.0); - - textureStore(output_tex, id.xy, vec4f(clamped, clamped, clamped, 1.0)); -} |
