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 --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8d08b..66dba79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -488,6 +488,10 @@ if(DEMO_BUILD_TESTS) target_link_libraries(test_shader_compilation PRIVATE gpu util procedural ${DEMO_LIBS}) add_dependencies(test_shader_compilation generate_demo_assets) + add_demo_test(test_noise_functions NoiseFunctionsTest src/tests/test_noise_functions.cc ${PLATFORM_SOURCES} ${GEN_DEMO_CC}) + target_link_libraries(test_noise_functions PRIVATE gpu util procedural ${DEMO_LIBS}) + add_dependencies(test_noise_functions generate_demo_assets) + add_demo_test(test_uniform_helper UniformHelperTest src/tests/test_uniform_helper.cc) target_link_libraries(test_uniform_helper PRIVATE gpu util ${DEMO_LIBS}) -- cgit v1.2.3