<feed xmlns='http://www.w3.org/2005/Atom'>
<title>demo.git/assets/final/shaders/math, branch main</title>
<subtitle>Vide-coded 64k demo system</subtitle>
<id>https://git.taar-o.com/demo.git/atom?h=main</id>
<link rel='self' href='https://git.taar-o.com/demo.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/'/>
<updated>2026-02-13T07:21:34Z</updated>
<entry>
<title>Refactor: Reorganize workspaces and remove assets/ directory</title>
<updated>2026-02-13T07:21:34Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-13T07:21:34Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=eb15703a3f87e4eadc8839b06de12b9c6ec54023'/>
<id>urn:sha1:eb15703a3f87e4eadc8839b06de12b9c6ec54023</id>
<content type='text'>
Workspace structure now:
- workspaces/{main,test}/obj/      (3D models)
- workspaces/{main,test}/shaders/  (WGSL shaders)
- workspaces/{main,test}/music/    (audio samples)

Changes:
- Moved workspaces/*/assets/music/ → workspaces/*/music/
- Updated assets.txt paths (assets/music/ → music/)
- Moved test_demo.{seq,track} to tools/
- Moved assets/originals/ → tools/originals/
- Removed assets/common/ (legacy, duplicated in workspaces)
- Removed assets/final/ (legacy, superseded by workspaces)
- Updated hot-reload paths in main.cc
- Updated CMake references for test_demo and validation
- Updated gen_spectrograms.sh paths

handoff(Claude): Workspace reorganization complete
</content>
</entry>
<entry>
<title>feat(gpu): Add WGSL noise and hash function library (Task #59)</title>
<updated>2026-02-08T18:09:05Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-08T18:09:05Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=cd807732799904f6731f460cc0469143c410c2c9'/>
<id>urn:sha1:cd807732799904f6731f460cc0469143c410c2c9</id>
<content type='text'>
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 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>feat(shaders): Add bump-mapped normal calculation variants</title>
<updated>2026-02-08T16:09:15Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-08T16:09:15Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=e160583feabe4c1c28e9107cb4d5be5e68861baf'/>
<id>urn:sha1:e160583feabe4c1c28e9107cb4d5be5e68861baf</id>
<content type='text'>
Adds two new functions for displacement-mapped normal calculation:

Functions added:
- get_normal_bump(): High-quality 6-sample central differences
- get_normal_bump_fast(): Optimized 4-sample tetrahedron pattern

Performance comparison:
- get_normal_bump: 6 SDF + 6 texture + 6 UV = 18 operations
- get_normal_bump_fast: 4 SDF + 4 texture + 4 UV = 12 operations
- Speed improvement: 33% faster with tetrahedron method

Parameters:
- p: Sample position (vec3)
- obj_params: Object parameters (vec4)
- noise_tex: Displacement texture (texture_2d)
- noise_sampler: Texture sampler
- disp_strength: Displacement strength multiplier

Requirements:
- spherical_uv() function must be available in calling context
- get_dist() function must be available in calling context

Use cases:
- get_normal_bump: Static scenes, high-quality renders
- get_normal_bump_fast: Real-time rendering, performance-critical paths

Location: assets/final/shaders/math/sdf_utils.wgsl
</content>
</entry>
<entry>
<title>feat(shaders): Add optimized 4-sample SDF normal estimation</title>
<updated>2026-02-08T16:04:42Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-08T16:04:42Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=5301e00826da6ff935bd42649f153d109eaef3b6'/>
<id>urn:sha1:5301e00826da6ff935bd42649f153d109eaef3b6</id>
<content type='text'>
Adds get_normal_fast() variant using tetrahedral gradient approximation.

Performance improvement:
- 4 SDF evaluations (vs 6 in get_normal_basic)
- ~33% fewer distance field samples
- Tetrahedron pattern: k.xyy, k.yyx, k.yxy, k.xxx where k=(1,-1)

Trade-off:
- Slightly less accurate than central differences method
- Good for real-time rendering where performance matters
- Same sphere optimization (analytical normal for obj_type == 1.0)

Parameters:
- epsilon: 0.0001 (vs 0.001 in basic method)
- Same interface: takes position and object params

Use case: Fast lighting calculations, performance-critical shaders
</content>
</entry>
<entry>
<title>feat(shaders): Extract common WGSL utilities for better composability</title>
<updated>2026-02-08T14:52:26Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-08T14:52:26Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=8d3c540e097a659d7ac9b1594a0b00404002925f'/>
<id>urn:sha1:8d3c540e097a659d7ac9b1594a0b00404002925f</id>
<content type='text'>
Created math/common_utils.wgsl with reusable shader functions:
- transform_normal() - Normal matrix transform (2 call sites)
- spherical_uv() - Spherical UV mapping (7 call sites)
- spherical_uv_from_dir() - For direction vectors (1 call site)
- grid_pattern() - Procedural checkerboard (2 call sites)
- Constants: PI, TAU

Refactored shaders:
- renderer_3d.wgsl: 7 spherical_uv + 1 normal + 2 grid (~12 lines removed)
- mesh_render.wgsl: 1 normal transform (~3 lines removed)
- skybox.wgsl: 1 spherical UV (~2 lines removed)

Impact: ~200 bytes saved, 12 call sites deduplicated
Tests: 31/31 passing

Co-Authored-By: Claude Sonnet 4.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>fix(shaders): Resolve WGSL validation errors and add shader compilation tests</title>
<updated>2026-02-06T13:08:09Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-06T13:08:09Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=1e3e3f54a4f80bd05d168c9ae749ed32e1275868'/>
<id>urn:sha1:1e3e3f54a4f80bd05d168c9ae749ed32e1275868</id>
<content type='text'>
Fixed three critical WGSL shader issues causing demo64k and test_3d_render to crash:

1. **renderer_3d.wgsl**: Removed dead code using non-existent `inverse()` function
   - WGSL doesn't have `inverse()` for matrices
   - Dead code was unreachable but still validated by shader compiler
   - Also removed reference to undefined `in.normal` vertex input

2. **sdf_utils.wgsl &amp; lighting.wgsl**: Fixed `get_normal_basic()` signature mismatch
   - Changed parameter from `obj_type: f32` to `obj_params: vec4&lt;f32&gt;`
   - Now correctly matches `get_dist()` function signature

3. **scene_query_linear.wgsl**: Fixed incorrect BVH binding declaration
   - Linear mode was incorrectly declaring binding 2 (BVH buffer)
   - Replaced BVH traversal with simple linear object loop
   - Root cause: Both BVH and Linear shaders were identical (copy-paste error)

Added comprehensive shader compilation test (test_shader_compilation.cc):
- Tests all production shaders compile successfully through WebGPU
- Validates both BVH and Linear composition modes
- Catches WGSL syntax errors, binding mismatches, and type errors
- Would have caught all three bugs fixed in this commit

Why tests didn't catch this:
- Existing test_shader_assets only checked for keywords, not compilation
- No test actually created WebGPU shader modules from composed code
- New test fills this gap with real GPU validation

Results:
- demo64k runs without WebGPU errors
- test_3d_render no longer crashes
- All 22/23 tests pass (FftTest unrelated issue from FFT Phase 1)

Co-Authored-By: Claude Sonnet 4.5 &lt;noreply@anthropic.com&gt;
</content>
</entry>
<entry>
<title>feat(perf): Add toggle for GPU BVH and fix fallback</title>
<updated>2026-02-06T00:38:51Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-06T00:38:51Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=ae4b03ef6f5ef07dcc80affd6877d17fceee7d29'/>
<id>urn:sha1:ae4b03ef6f5ef07dcc80affd6877d17fceee7d29</id>
<content type='text'>
Completed Task #18-B.
- Implemented GPU-side BVH traversal for scene queries, improving performance.
- Added a --no-bvh command-line flag to disable the feature for debugging and performance comparison.
- Fixed a shader compilation issue where the non-BVH fallback path failed to render objects.
</content>
</entry>
<entry>
<title>feat(gpu): Implement recursive WGSL composition and modularize shaders (Task #50)</title>
<updated>2026-02-04T10:56:03Z</updated>
<author>
<name>skal</name>
<email>pascal.massimino@gmail.com</email>
</author>
<published>2026-02-04T10:56:03Z</published>
<link rel='alternate' type='text/html' href='https://git.taar-o.com/demo.git/commit/?id=2e34965e5e48175c5ee6016af1a858f7f3f02c1d'/>
<id>urn:sha1:2e34965e5e48175c5ee6016af1a858f7f3f02c1d</id>
<content type='text'>
- Updated ShaderComposer to support recursive #include "snippet_name" with cycle detection.
- Extracted granular WGSL snippets: math/sdf_shapes, math/sdf_utils, render/shadows, render/scene_query, render/lighting_utils.
- Refactored Renderer3D to use #include in shaders, simplifying C++ dependency lists.
- Fixed WGPUShaderSourceWGSL usage on macOS to correctly handle composed shader strings.
- Added comprehensive unit tests for recursive composition in test_shader_composer.
- Verified system stability with test_3d_render and full test suite.
- Marked Task #50 as recurrent for future code hygiene.
</content>
</entry>
</feed>
