summaryrefslogtreecommitdiff
path: root/assets/final/shaders/compute
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-09 13:52:37 +0100
committerskal <pascal.massimino@gmail.com>2026-02-09 13:52:37 +0100
commitc712874ece1ca7073904f5fb84cc866d28084de0 (patch)
treef46727b58d3ac0e4ba3f36d50ea147c086282232 /assets/final/shaders/compute
parent0151a43cd179bd08584347e13327a3a722bddf2a (diff)
feat(gpu): Add GPU procedural texture generation system
Phase 1 implementation complete: - GPU compute shader for noise generation (gen_noise.wgsl) - TextureManager extensions: create_gpu_noise_texture(), dispatch_noise_compute() - Asset packer PROC_GPU() syntax support with validation - ShaderComposer integration for #include resolution - Zero CPU memory overhead (GPU-only textures) - Init-time and on-demand generation modes Technical details: - 8×8 workgroup size for 256×256 textures - UniformBuffer for params (width, height, seed, frequency) - Storage texture binding (rgba8unorm, write-only) - Lazy pipeline compilation on first use - ~300 bytes code (Phase 1) Testing: - New test: test_gpu_procedural.cc (passes) - All 34 tests passing (100%) Future phases: - Phase 2: Add gen_perlin, gen_grid compute shaders - Phase 3: Variable dimensions, async generation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'assets/final/shaders/compute')
-rw-r--r--assets/final/shaders/compute/gen_noise.wgsl26
1 files changed, 26 insertions, 0 deletions
diff --git a/assets/final/shaders/compute/gen_noise.wgsl b/assets/final/shaders/compute/gen_noise.wgsl
new file mode 100644
index 0000000..5c0babd
--- /dev/null
+++ b/assets/final/shaders/compute/gen_noise.wgsl
@@ -0,0 +1,26 @@
+// 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 = vec2<f32>(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, vec4<f32>(noise, noise, noise, 1.0));
+}