From cd807732799904f6731f460cc0469143c410c2c9 Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 19:09:05 +0100 Subject: feat(gpu): Add WGSL noise and hash function library (Task #59) Implements comprehensive RNG and noise functions for procedural shader effects: Hash Functions: - hash_1f, hash_2f, hash_3f (float-based, fast) - hash_2f_2f, hash_3f_3f (vector output) - hash_1u, hash_1u_2f, hash_1u_3f (integer-based, high quality) Noise Functions: - noise_2d, noise_3d (value noise with smoothstep) - fbm_2d, fbm_3d (fractional Brownian motion) - gyroid (periodic minimal surface) Integration: - Added to ShaderComposer as "math/noise" snippet - Available via #include "math/noise" in WGSL shaders - Test suite validates all 11 functions compile Testing: - test_noise_functions.cc validates shader loading - All 33 tests pass (100%) Size Impact: ~200-400 bytes per function used (dead-code eliminated) Files: - assets/final/shaders/math/noise.wgsl (new, 4.2KB, 150 lines) - assets/final/demo_assets.txt (added SHADER_MATH_NOISE) - assets/final/test_assets_list.txt (added SHADER_MATH_NOISE) - src/gpu/effects/shaders.cc (registered snippet) - src/tests/test_noise_functions.cc (new test) - CMakeLists.txt (added test target) Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/shaders.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gpu/effects/shaders.cc') diff --git a/src/gpu/effects/shaders.cc b/src/gpu/effects/shaders.cc index 380b5b4..ce60a74 100644 --- a/src/gpu/effects/shaders.cc +++ b/src/gpu/effects/shaders.cc @@ -35,6 +35,7 @@ void InitShaderComposer() { register_if_exists("math/sdf_utils", AssetId::ASSET_SHADER_MATH_SDF_UTILS); register_if_exists("math/common_utils", AssetId::ASSET_SHADER_MATH_COMMON_UTILS); + register_if_exists("math/noise", AssetId::ASSET_SHADER_MATH_NOISE); register_if_exists("render/shadows", AssetId::ASSET_SHADER_RENDER_SHADOWS); register_if_exists("render/scene_query_bvh", AssetId::ASSET_SHADER_RENDER_SCENE_QUERY_BVH); -- cgit v1.2.3