summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2026-03-07streamline docskal
2026-03-07feat(tools): add offline WGSL validator + fix ntsc.wgsl syntaxskal
- scripts/validate_shaders.py: compose #includes then validate with naga-cli (mirrors InitShaderComposer snippet map; skips runtime-substitution shaders) - src/effects/ntsc.wgsl: remove broken GLSL-syntax vignette() function (GLSL const/param syntax, f32→vec2f assignment; inline vignette at line 55 already handles darkening) handoff(Gemini): validator at scripts/validate_shaders.py; install naga with cargo install naga-cli; 29/29 shaders pass Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07fix(cmake): normalize asset paths to fix incremental rebuild trackingskal
Paths like ../../src/effects/ntsc.wgsl were stored non-normalized in the DEPENDS list, preventing Ninja/Make from detecting file changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07feat(effects): add Ntsc post-process effect with fisheye distortionskal
WGSL-only WgslEffect implementing barrel/fisheye distortion, RGB chroma separation, scanlines, per-pixel temporal noise, rolling jitter line, vignette, and warm NTSC phosphor tint. Applied across all main sequences. handoff(Gemini): Ntsc effect added; 13 effects total, 35+1 tests expected. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07refactor(effects): introduce WgslEffect for shader-only post-process effectsskal
Replace boilerplate .h/.cc pairs for simple single-pass effects with a generic WgslEffect base class that takes a shader string + optional WgslEffectParams (binding 3). Port Flash, Passthrough, Heptagon, Scratch, and GaussianBlur to thin header-only wrappers — no .cc files, no CMake entries needed. Removes 5 .cc files (-243 lines). Update EFFECT_WORKFLOW.md, CONTRIBUTING.md, and AI_RULES.md to document the WgslEffect (Path A) vs full class (Path B) workflow. Doc cleanup: fix stale GaussianBlurParams/PostProcessEffect references and test counts. handoff(Claude): WgslEffect landed; 5 effects ported; docs updated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06feat(effects): add Scratch post-process effect with reusable scratch_lines ↵skal
snippet - src/shaders/render/scratch_lines.wgsl: reusable WGSL snippet registered as "render/scratch_lines"; call scratch_lines(uv, resolution, time)->f32 from any effect. Uses hash_1f from math/noise; 8 lines/frame, ~24fps flicker. - src/effects/scratch.{wgsl,h,cc}: thin Scratch effect wrapping the snippet. - Applied to "intro" and "rotating_cube" sequences as the final step. - 35/35 tests passing. handoff(Gemini): Scratch effect added. render/scratch_lines snippet is reusable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06test: remove obsolete test_sequence.ccskal
2026-03-05style: run clang-format to adhere to coding styleskal
2026-03-05fix(test): WavDumpBackendTest uses sine tone instead of empty ring bufferskal
Without music loaded, synth renders silence; reading from the ring buffer yielded all-zero samples causing the non_zero_count assertion to fail. Replace the ring-buffer read path with a direct 440 Hz sine wave so the test focuses on WAV format/encoding, not audio pipeline content. handoff(Claude): WavDumpBackendTest now passes (35/35 tests green). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05fix(audio): correct OLA synthesis and extract shared ola_encode/ola_decodeskal
- Remove erroneous Hann synthesis window from synth.cc (g_hann * tmp[j]). Hann analysis at 50% overlap satisfies w[n]+w[n+H]=1, so rectangular synthesis gives perfect reconstruction; applying Hann twice was wrong. - Extract ola_encode()/ola_decode()/ola_num_frames() into src/audio/ola.h+cc. spectool and test_wav_roundtrip now use the shared functions. synth.cc lazy-decode path stays inlined (see TODO for future refactor). - Drop dead <atomic> include and g_hann array from synth.cc. - Drop dead window.h include from spectool.cc. - Update PROJECT_CONTEXT.md, COMPLETED.md, TODO.md to reflect correct analysis-only Hann window and new ola.h API. handoff(Gemini): OLA synthesis bug fixed + ola.h factorized. synth.cc lazy-decode still inline (TODO item added). 34/35 tests pass; WavDumpBackendTest failure is pre-existing and unrelated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05feat(spectool): add --wav decode, IMDCT, and roundtrip testskal
- spectool --wav <input.spec> <output.wav>: decodes .spec to mono 16-bit WAV at 32 kHz using IDCT-OLA synthesis (no synthesis window). The analysis Hann window at 50% overlap satisfies w[n]+w[n+H]=1, so the synthesis window must be rectangular for perfect reconstruction. - Add imdct_512 / imdct_fft to audio lib (fft.cc, fft.h, idct.cc, dct.h) for future MDCT-based synthesis. - test_wav_roundtrip: in-process OLA analyze+decode SNR test (≥30 dB). Currently measures 53 dB on a 440 Hz sine. - Fix stale test_spectool.cc: version assertion updated from 1 to SPEC_VERSION_V2_OLA (was always wrong since OLA fix landed). - Docs: TOOLS_REFERENCE.md removes dead specview, documents --wav / --normalize / test_gen. HOWTO.md adds decode section. TRACKER.md notes spec v2 OLA format and decode command. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05fix(audio): OLA encoder never ran; version never propagated to decoderskal
Two bugs kept the v2 OLA path permanently disabled: 1. SpectrogramResourceManager::load_asset() never set spec.version from SpecHeader::version — all .spec assets loaded with version=0, so ola_mode was always false in the voice. 2. spectool analyze_audio() used non-overlapping chunks (stride=DCT_SIZE), hamming_window_512, and hardcoded header.version=1 — OLA analysis was never implemented in the encoder. Fixes: propagate header->version in load_asset(); switch spectool to OLA_HOP_SIZE stride, hann_window_512, and SPEC_VERSION_V2_OLA. Regenerated all .spec files. handoff(Gemini): OLA enc/dec chain now correct end-to-end. .spec files are v2 (50% overlap, Hann). No API changes; 33/34 tests pass (WavDumpBackendTest pre-existing failure unrelated). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03test(assets): add MP3 asset type test (TEST_MP3/ASSET_TEST_MP3)skal
Adds a minimal test.mp3 fixture to the test workspace and verifies GetAssetType returns AssetType::MP3 and GetAsset returns non-null data. handoff(Gemini): MP3 asset test added, 34/34 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03feat(assets): replace is_procedural/is_gpu_procedural bools with AssetType ↵skal
enum, add MP3 type - Add AssetType enum {STATIC, PROC, PROC_GPU, MP3} to AssetRecord - Add GetAssetType() API to asset_manager.h/cc - asset_packer: parse 'MP3' compression keyword in assets.txt - tracker: remove magic-byte is_mp3_asset(); use GetAssetType() instead - assets.txt: NEVER_MP3 now uses 'MP3' compression type - doc/ASSET_SYSTEM.md: rewritten to document new types and API handoff(Gemini): AssetType enum landed; MP3 detection is now explicit via asset metadata.
2026-03-02feat(audio): OLA-IDCT synthesis with Hann window to eliminate clicksskal
Add v2 spectrogram format (SPEC_VERSION_V2_OLA) using overlap-add IDCT with 50% overlap (hop=256, OLA_OVERLAP=256) and Hann windowing. - dct.h: OLA_HOP_SIZE=256, OLA_OVERLAP=256 - synth.h: SPEC_VERSION_V1/V2_OLA constants; version field on Spectrogram - window.h/cc: hann_window_512() alongside existing hamming_window_512() - synth.cc: g_hann[] precomputed at init; OLA path in synth_render when ola_mode=true (IDCT -> Hann -> add overlap tail -> save new tail -> output OLA_HOP_SIZE samples); v1 path unchanged for backward compat - tracker.cc: MP3 encoder now uses sliding 512-sample Hann window with OLA_HOP_SIZE advance per frame; sets version=SPEC_VERSION_V2_OLA; .spec files propagate header->version; generated notes stay v1 Existing .spec files must be regenerated to benefit from click-free OLA. handoff(Claude): OLA done. .spec files need regen via MP3 tool to activate v2.
2026-03-02feat(audio): MP3 asset support in tracker via decode-at-initskal
Detect MP3 blobs by magic bytes in tracker_init(), decode to spectrogram (hamming window + FDCT) using new mp3_decode(), and register with synth exactly like .spec assets. STRIP_ALL builds guard with FATAL_CHECK. handoff(Gemini): MP3 assets now usable in music.track with SAMPLE ASSET_* syntax; see doc/TRACKER.md for usage. No synth/compiler/packer changes. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01feat(audio): add experimental MP3 on-demand range decoderskal
Adds mp3_open/mp3_decode_range/mp3_close API backed by miniaudio ma_decoder for in-memory MP3 assets. Guarded by #if !defined(STRIP_ALL); any use in stripped builds is a compile error. No new dependencies: drmp3 is already compiled via MINIAUDIO_IMPLEMENTATION in audio.cc. handoff(Gemini): mp3_sample.{h,cc} in AUDIO_SOURCES. Usage: Mp3Decoder* d = mp3_open(GetAsset(id, &sz), sz); mp3_decode_range(d, start_frame, num_frames, pcm_out); mp3_close(d); Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28refactor(effects): co-locate effect WGSL shaders with their .h/.cc in ↵skal
src/effects/ Move 13 effect-specific shaders from workspaces/main/shaders/ to src/effects/ so each effect's .h, .cc, and .wgsl are together. Update assets.txt paths in both main and test workspaces. Update EFFECT_WORKFLOW.md to reflect new location. Shared/reusable snippets remain in src/shaders/. handoff(Gemini): shaders moved; src/effects/ now has .h, .cc, and .wgsl per effect. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28fix Scene2 -> Scene2Effectskal
2026-02-28fix(tools/shadertoy): fix Next Steps instructions and update EFFECT_WORKFLOW.mdskal
- Fix assets.txt path: shaders/xxx.wgsl (not ../../src/shaders/) - Fix shader output path to workspaces/main/shaders/ - Step 5: reference cmake/DemoSourceLists.cmake COMMON_GPU_EFFECTS (not CMakeLists.txt GPU_SOURCES) - Add step for test_demo_effects.cc Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28refactor: move common/shaders/ to src/shaders/skal
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>
2026-02-28remove unused util/math.hskal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28misc: cleanup comments and formatting in headersskal
- asset_manager_dcl.h: clarify purpose vs asset_manager.h - camera_params.h: broaden description to include 3D rendering - sdf_cpu.h: simplify calc_normal formatting - platform.h: add missing newline at EOF Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28refactor(gpu): move RenderPipelineBuilder impl to pipeline_builder.ccskal
Keeps .h as declarations only; moves all method bodies to .cc. Adds pipeline_builder.cc to COMMON_GPU_EFFECTS in DemoSourceLists.cmake. handoff(Claude): pipeline_builder split to .h/.cc, builds clean.
2026-02-28refactor(gpu): move SamplerCache impl to .cc, expose single entry pointskal
get_or_create() and clear() moved out of the header-only class. SamplerSpec and presets remain inline (trivial, no deps). handoff(Gemini): sampler_cache split into .h/.cc, sampler_cache.cc added to COMMON_GPU_EFFECTS. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28remove SDFEffect base class and sdf_test, update SDF_EFFECT_GUIDEskal
- Delete unused SDFEffect base class (src/gpu/sdf_effect.h) - Delete sdf_test.wgsl and SHADER_SDF_TEST from assets.txt - Rewrite SDF_EFFECT_GUIDE.md based on Scene1 canonical pattern: correct bindings (2/3), vec4f syntax, UniformsSequenceParams - Fix missing newline at end of gpu.h handoff(Claude): SDF cleanup done, guide updated to match current Effect API
2026-02-28remove vestigial demo_effects.ccskal
handoff(Gemini): deleted src/gpu/demo_effects.cc (empty stub), removed from headless GPU_SOURCES in DemoSourceLists.cmake, dropped stale #include from post_process_helper.cc. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28replace wgsl type: vec4<f32> -> vec4f ..skal
2026-02-28fix: double-free of external views in NodeRegistry and PASSTHROUGH shader testskal
- NodeRegistry: skip external nodes (texture==nullptr) in ~NodeRegistry() and resize() to avoid double-releasing views set via set_external_view() - test_shader_assets: update PASSTHROUGH check to match #include pattern handoff(Claude): 35/35 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-28fix(shaders): deduplicate VertexOutput/vs_main via render/fullscreen_uv_vs ↵skal
snippet - Fix vs_main return type (VertexOutput, not vec4<f32>) - Fix #include paths in passthrough, gaussian_blur, heptagon, combined_postprocess - ShaderComposer: assert + suggest correct path on missing #include (non-STRIP_ALL) - VerifyIncludes: upgrade WARNING to ERROR + assert, add "did you mean?" hint Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-21test: fix test_effect_base intermittent crashes and SIGTRAPskal
- Fix stack-use-after-scope dangling reference by storing mutable GpuContext in WebGPUTestFixture. - Fix wgpuDevicePoll causing SIGTRAP and replace with target.read_pixels() to block for GPU teardown safely. - Fix WGPUCommandEncoder leak.
2026-02-21refactor(wgsl): Use vec*f alias for vector typesskal
Replaces all instances of `vec<f32>` with the more concise `vec*f` alias (e.g., `vec3f`) across all `.wgsl` shaders. This improves readability and aligns with common graphics programming conventions. Also adds a new coding style rule to `doc/CODING_STYLE.md` to enforce this standard going forward. Finally, this commit fixes a build error in `test_effect_base.cc` by replacing a call to the non-existent `wgpuDeviceTick` with `wgpuDevicePoll`, which resolves the test failure.
2026-02-21fix(tests): Resolve intermittent SIGTRAP in test_effect_baseskal
The test `test_sequence_render` was disabled due to an intermittent SIGTRAP. The issue was caused by the test application exiting before the GPU finished rendering. This commit fixes the issue by adding a call to `wgpuDeviceTick()` after submitting the command buffer. This ensures that the GPU has completed its work before the test finishes. The test is now re-enabled and passes consistently.
2026-02-21split raymarching.wgsl in two: with id, or without id.skal
2026-02-21feat(math): Add vec3::rotate methods for quaternion and axis-angle rotationskal
Adds two convenient methods to the struct: - : Rotates the vector by a given quaternion. - : Rotates the vector around a given axis by an angle in radians. These functions provide a more intuitive and streamlined syntax for vector rotation, improving code readability and usability.
2026-02-21feat: Add vec3::rotate function for quaternion rotation.skal
2026-02-21refine scene1 shaderskal
2026-02-20feat(scene1): replace ad-hoc camera with CameraParams uniformskal
Build camera via mat4::look_at + inverse in scene1_effect.cc, upload as CameraParams at binding 3. Shader uses getCameraRay() from camera_common. Enable camera_common snippet registration in shaders.cc. handoff(Claude): Scene1 camera now driven by CameraParams uniform; fov=TAU/6 (60° vFOV) matches original tan(PI/3) parameterization. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-20feat(sequence): port Scene1Effect + fix seq_compiler absolute time bugskal
- Add Scene1 effect: raymarching cube+sphere+ground (reflections, shadows) - Fix scene1.wgsl: binding 0→2, CommonUniforms→UniformsSequenceParams - Replace Heptagon+Placeholder stub in heptagon_scene with Scene1 - Fix seq_compiler.py: emit seq.start_time+effect.start/end (absolute times) so dispatch_render active check works correctly for all sequences Bug: effects in sequences starting after t=0 were never active because local times (e.g. 0-8) never satisfied params.time<end for absolute time 20+. 34/34 tests passing. handoff(Gemini): seq_compiler now emits absolute effect times. All existing sequences affected — verify visual output across the full timeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-17feat(uniforms): Add noise field with per-frame random valuesskal
Replace _pad with noise field in UniformsSequenceParams, providing effects with non-deterministic random values [0..1] updated each frame. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17refactor(effects): Streamline uniforms initializationskal
Centralized uniforms_buffer_ initialization and updates to Effect base class: - init_uniforms_buffer() now automatic in Effect::Effect() - uniforms_buffer_.update() now automatic in dispatch_render() - Removed redundant calls from all effect subclasses - Updated effect.h comments to reflect automatic behavior - Updated EFFECT_WORKFLOW.md templates Benefits: - 16 lines removed from effect implementations - Consistent pattern enforced at compile time - Reduced boilerplate for new effects Tests: 34/34 passing handoff(Claude): Effect base class now handles uniforms automatically
2026-02-17refactor(gpu): Add RAII wrapper for WGPU resources to eliminate manual cleanupskal
Introduces WGPUResource template with automatic release on destruction. Reduces boilerplate in effect destructors and prevents resource leaks. - set() for one-time initialization - replace() for per-frame recreation - Field ordering documented for dependency management Converted 3 effects (Heptagon, Flash, Passthrough) and Effect base class. All tests pass (34/34). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17refactor(effects): Factor shared initialization into Effect base classskal
Eliminate ~100 lines of duplicated code across effect subclasses by moving common resource initialization to the base Effect class. Most effects repeatedly created uniforms buffers, samplers, and dummy textures with identical configurations. Changes: - Add shared members to Effect: uniforms_buffer_, sampler_, dummy_texture_* - Add helpers: init_uniforms_buffer(), create_*_sampler(), create_dummy_scene_texture() - Add gpu_create_*_sampler() and gpu_create_dummy_scene_texture() to gpu.h - Move HEADLESS_RETURN_IF_NULL to Effect constructor - Update 7 effects to use base class helpers (Flash, Heptagon, Passthrough, Placeholder, GaussianBlur, Particles, PeakMeter) Benefits: Improved consistency, easier maintenance, reduced binary size. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17docs(gpu): Purge comment bloat from GPU headersskal
Removed redundant and obvious comments from 7 GPU headers: - post_process_helper.h: binding comments, stale UniformsSequenceParams note - shader_composer.h: verbose Compose/VerifyIncludes descriptions - uniform_helper.h: obvious method comments - effect.h: redundant render/resize comments - gpu.h: verbose struct/header comments, GPU perf placeholder - sdf_effect.h: obvious method comments - sequence.h: duplicate header, obvious API comments Kept only non-obvious context (binding conventions, headless mode notes). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17refactor(gpu): Remove stale v2 references from demo_effectsskal
Removed outdated comments referencing old naming conventions and non-existent functions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17fix(build): Resolve Windows cross-compilation failuresskal
This commit fixes several issues that caused the Windows cross-compilation build (`scripts/build_win.sh`) to fail. The root causes were platform-specific API differences in the wgpu-native library and incorrect dependency tracking in the CMake build system for generated code. Changes: - **`tools/seq_compiler.py`**: The timeline generator now wraps `depthSlice` assignments in `#if !defined(DEMO_CROSS_COMPILE_WIN32)` directives to handle API differences in `WGPURenderPassColorAttachment`. - **`src/gpu/gpu.h`**: The `gpu_init_color_attachment` helper is now platform-aware, using a preprocessor guard for the `depthSlice` member. - **`src/effects/*.cc`**: All effects are updated to use the new platform-aware helper or have explicit guards for `depthSlice`. Also, replaced `WGPUTexelCopyTextureInfo` with the cross-platform alias `GpuTextureCopyInfo` in `rotating_cube_effect.cc`. - **`cmake`**: Added `tools/seq_compiler.py` as an explicit dependency to the `generate_timeline` and `generate_test_demo_timeline` custom commands. This ensures that changes to the generator script correctly trigger a rebuild of the generated C++ files. - **`scripts/build_win.sh`**: Removed the erroneous attempt to build the `seq_compiler.py` script as a native executable. With these changes, the Windows cross-compilation build now completes successfully.
2026-02-17refactor(3d): SceneLoader to namespaceskal
Refactors the SceneLoader class to a namespace. Since it only contained a single static utility function, a namespace is a more appropriate and idiomatic C++ construct. No functional changes.
2026-02-17feat: Rename GPU stub and headless files and update referencesskal
2026-02-17style: replace C++ casts with C-style castsskal
Converts all static_cast<>, reinterpret_cast<> to C-style casts per CODING_STYLE.md guidelines. - Modified 12 files across gpu, 3d, util, tests, and tools - All builds passing, 34/34 tests passing - No functional changes, pure style cleanup Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17refactor: centralize platform-specific code in gpu.hskal
Move platform-specific type definitions to gpu.h and establish coding rule that platform ifdefs must be confined to gpu/platform layers. - gpu.h: add GpuTextureCopyInfo, GpuTextureDataLayout type aliases - effect.cc: use GpuTextureCopyInfo instead of platform ifdefs - texture_manager.cc: use type aliases and label_view() helper - CODING_STYLE.md: add platform-specific code section with rule Tests: 34/34 passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>