summaryrefslogtreecommitdiff
path: root/src/effects
AgeCommit message (Collapse)Author
12 daysfix(particles): release compute and render pass encodersskal
Missing wgpuComputePassEncoderRelease/wgpuRenderPassEncoderRelease caused per-frame leaks and command buffer corruption in wgpu-native. handoff(Gemini): particles encoder leak fixed, 2 lines added to render() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
12 dayschange dither_c64() signature to take 'dimension' directlyskal
12 daysntsc: factor common code into snippet; add RGB and YIQ input variantsskal
- Extract shared NTSC logic into render/ntsc_common.wgsl snippet - sample_ntsc_signal() hook decouples input format from processing - ntsc_rgb.wgsl: RGB input (converts via rgba_to_luma_chroma_phase) - ntsc_yiq.wgsl: YIQ passthrough for RotatingCube output - Add NtscYiq WgslEffect thin wrapper; register both in tests handoff(Claude): NTSC refactor complete; NtscYiq ready for timeline use with RotatingCube. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 daysrotating_cube: use VSOut, and store to yiqskal
13 daysfix: use ShaderComposer in RotatingCube; add rule to CODING_STYLEskal
rotating_cube_effect.cc was bypassing ShaderComposer, causing #include directives in rotating_cube.wgsl to fail at runtime. handoff(Claude): ShaderComposer rule documented and enforced in rotating_cube. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 daysstyle: require 2-line header comment in all .wgsl filesskal
Add rule to CODING_STYLE.md and apply to ntsc.wgsl. handoff(Claude): rule added, ntsc.wgsl patched; scratch_lines and color_c64 already compliant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
13 daysNTSC: use 6-taps filtering instead of 12-tapskal
14 daysrefactor: mv get_border_col() to color_c64.wgsl as get_border_c64()skal
14 daysfeat: register math/color_c64 snippet in ShaderComposerskal
14 daysrefactor: extract YIQ and C64 dither to common WGSL shadersskal
- math/color.wgsl: add rgba_to_yiqa, yiqa_to_rgba, rgba_to_luma_chroma_phase - math/color_c64.wgsl: new file with C64 palette, Bayer 8x8, Dither() - ntsc.wgsl: include both, remove local duplicates; Dither() now takes xsize/ysize handoff(Claude): YIQ/dither helpers now reusable by other effects
14 daysadd ditheringskal
14 daysntsc effect for realskal
2026-03-08fix: negate Y in perspective() to correct rasterized 3D orientationskal
The fullscreen post-process VS uses Y-up UVs (uv.y=0 = bottom), so textureSample() Y-flips any rasterized offscreen texture. SDF effects author their content Y-down and look correct after the flip. Rasterized effects (RotatingCube, Hybrid3D) must pre-flip their geometry: - mat4::perspective(): m[5] = -t (negated Y scale) - Pipelines with cullMode=Back: frontFace = WGPUFrontFace_CW (Y-flip reverses winding, so CW becomes the visible face) - Remove incorrect transposes from GlobalUniforms::make(), ObjectData::make(), and Uniforms::make() — mini_math is column-major, no transpose needed for GPU upload - Document the convention in doc/3D.md under "Rasterized 3D and the Y-flip rule" handoff(Gemini): Y-flip rule now documented; all rasterized 3D pipelines must follow it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08fix: register debug/debug_print snippet in ShaderComposerskal
Add SHADER_DEBUG_DEBUG_PRINT to assets.txt and register it as "debug/debug_print" in InitShaderComposer() so ntsc.wgsl #include works. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08fix: transpose matrices on GPU upload (row-major → column-major)skal
mini_math mat4 is row-major; WGSL mat4x4f is column-major. Matrices uploaded without transposing were interpreted as their own transpose on the GPU, causing RotatingCube and Renderer3D to render upside-down. - Add gpu_upload_mat4() to post_process_helper for standalone uploads - Add Uniforms::make() to RotatingCube::Uniforms (handles transpose) - Add GlobalUniforms::make() and ObjectData::make() to renderer.h - Update renderer_draw.cc and visual_debug.cc to use make() handoff(Gemini): matrix layout bug fixed across all rasterized effects. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08feat: new cloudsskal
2026-03-08tweak: scene2.wgsl visual adjustmentsskal
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08feat: Implement dual-mode asset loading and update documentationskal
This commit introduces a dual-mode asset loading system to enhance developer workflow and optimize release builds. Key changes include: - **Dual-Mode Asset Loading:** Assets are now loaded from disk during development (when is OFF) for faster iteration, particularly for heavy assets like and files. For release builds ( ON), all assets are embedded directly into the binary, ensuring a single, self-contained executable. - **Explicit Asset Typing:** Replaced generic asset type with specific types (, , , , ) in and the enum in for clearer categorization and more robust processing. - **Build System Integration:** Modified to pass a flag to in development builds. - **Asset Packer Updates:** now generates file paths for disk-loaded assets and embeds data for others based on the build mode. - **Asset Manager Enhancements:** includes new logic in for loading and caching disk-based assets and updates to for proper memory deallocation. - **Documentation:** Updated to reflect the new asset nomenclature and dual-mode loading strategy. - **Project Rules:** Added a concise rule to mandating top-level documentation updates for medium/large sub-system changes. handoff(Gemini): Implemented dual-mode asset loading and updated documentation.
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-05style: run clang-format to adhere to coding styleskal
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(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-28replace wgsl type: vec4<f32> -> vec4f ..skal
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-21split raymarching.wgsl in two: with id, or without id.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-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-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-17feat: add time-based effect activation with auto-passthroughskal
Effects now accept start/end time parameters and automatically passthrough when inactive. Implements buffer chain integrity via compile-time validation. - Effect base class: dispatch_render() checks time bounds, auto-passthroughs 1:1 input/output effects outside [start, end] interval - seq_compiler.py: validates producer/consumer lifespan constraints for multi-output effects, adds --validate flag, always validates before codegen - Updated all 9 effect classes and test fixtures to pass start/end times - check_all.sh: includes timeline validation step - Tests: 34/34 passing, demo runs successfully Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-17style: Apply clang-formatskal
2026-02-17refactor: move shaders.{h,cc} to src/effects and remove v2 suffixskal
- Removed unused v1 shader declarations (13 variables) - Removed _v2 suffix from active shader names - Moved shaders.{h,cc} from src/gpu to src/effects - Updated all includes and build references - All tests pass (34/34) handoff(Claude): Cleaned up shader management, tests passing
2026-02-16fix: correct Heptagon effect rendering and SDF implementationskal
- Change draw call from 21 to 3 vertices (fullscreen triangle) - Replace broken folding-based SDF with IQ's atan-based regular polygon formula - Simplify test timeline to render Heptagon directly to sink - Reduce heptagon radius from 0.5 to 0.3 for better visibility The effect was not visible due to incorrect vertex count and broken SDF returning negative values everywhere (showing only fill color). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16fix: port Hybrid3D effect to sequence v2 architectureskal
Hybrid3D was calling Renderer3D::render() which creates its own command encoder, bypassing the sequence system. Now uses renderer_.draw() with the passed encoder. Also adds texture blit support for RotatingCube compositing. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16test: enhance GaussianBlur parameters and test timelineskal
- Fix shader struct to match C++ (add strength_audio, stretch) - Increase default blur strength to 8.0 for visibility - Add blur effect to test sequence for validation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16refactor: complete removal of 'Effect' suffix from C++ class namesskal
Update effect class definitions in headers and implementations to match timeline.seq naming convention. All tests passing (34/34). Classes renamed: - PassthroughEffect → Passthrough - GaussianBlurEffect → GaussianBlur - PlaceholderEffect → Placeholder - HeptagonEffect → Heptagon - ParticlesEffect → Particles - RotatingCubeEffect → RotatingCube - Hybrid3DEffect → Hybrid3D - FlashEffect → Flash - PeakMeterEffect → PeakMeter Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16feat: Add PeakMeterEffect v2 for test_demo audio visualizationskal
Ports PeakMeterEffect to v2 Effect system with proper DAG routing. Red horizontal bar overlay displays audio_intensity for visual debugging of audio-visual synchronization. Changes: - New: src/effects/peak_meter_effect.{h,cc} - v2 implementation - Timeline: FlashEffect -> flash_out -> PeakMeterEffect -> sink - Build: Added to COMMON_GPU_EFFECTS and demo_effects.h - Test: Added to test_demo_effects.cc (9/9 effects pass) - Cleanup: Removed old disabled PeakMeterEffect code from test_demo.cc Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16refactor(gpu): remove depthSlice conditionals, use platform.h abstractionskal
WGPU_DEPTH_SLICE_UNDEFINED is defined unconditionally via platform.h (native headers or Win32 macro). Remove redundant conditional compilation from 7 effects and gpu.h helper. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16feat: Add FlashEffect for audio/visual sync testingskal
- FlashEffect: Beat-synchronized white flash using ShaderComposer - Loads shader from assets (flash.wgsl) with sequence_uniforms include - Uses pow(1.0 - beat_phase, 4.0) for sharp flash at beat start - Updated test_demo.seq to use FlashEffect (was HeptagonEffect) - Added FlashEffect to test suite (test_demo_effects.cc) - Made cnn_test conditional on main workspace (fixes build error) - Flash intensity: 1.0 at beat start, fades to 0.0 by beat end Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16refactor(headless): convert nullptr checks to strippable macrosskal
Added HEADLESS_RETURN_IF_NULL/HEADLESS_RETURN_VAL_IF_NULL macros that compile to no-ops in STRIP_ALL/FINAL_STRIP modes. Files updated: - fatal_error.h: New headless check macros - sequence.cc: NodeRegistry::create_texture - post_process_helper.cc: Pipeline creation functions - sampler_cache.h: SamplerCache::get_or_create - bind_group_builder.h: Layout/group builders - pipeline_builder.h: Shader and pipeline builders - All effect constructors (7 files) Headless tests passing. STRIP_ALL builds will have zero overhead. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16fix(headless): add early returns to all effect constructorsskal
All effects now skip GPU resource creation when device is nullptr. Effects fixed: - GaussianBlurEffect - HeptagonEffect - Hybrid3DEffect - PassthroughEffect - ParticlesEffect Headless tests now passing (audio-only mode functional). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-16fix(headless): add nullptr checks for GPU resource creationskal
- NodeRegistry::create_texture: skip texture creation when device is nullptr - Post-process helpers: skip pipeline/bind group creation in headless mode - SamplerCache: return nullptr for headless mode - BindGroupLayoutBuilder/BindGroupBuilder: skip creation with null device - RenderPipelineBuilder: skip shader module and pipeline creation in headless - PlaceholderEffect: skip sampler creation in headless mode - RotatingCubeEffect: early return in constructor for headless mode WIP: Some effects (GaussianBlur, etc.) still need headless checks Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>