| Age | Commit message (Collapse) | Author |
|
Split monolithic asset_manager.h (61 lines) into 3 focused headers:
- asset_manager_dcl.h: Forward declarations (AssetId, ProcGenFunc)
- asset_manager.h: Core API (GetAsset, DropAsset, AssetRecord)
- asset_manager_utils.h: Typed helpers (TextureAsset, MeshAsset)
Updated 17 source files to use appropriate headers:
- object.h: Uses dcl.h (only needs AssetId forward declaration)
- 7 files using TextureAsset/MeshAsset: Use utils.h
- 10 files using only GetAsset(): Keep asset_manager.h
Performance improvement:
- Before: Touch asset_manager.h → 4.82s (35 files rebuild)
- After: Touch asset_manager_utils.h → 2.01s (24 files rebuild)
- Improvement: 58% faster for common workflow (tweaking mesh/texture helpers)
Note: Touching base headers (dcl/core) still triggers ~33 file rebuilds
due to object.h dependency chain. Further optimization would require
reducing object.h's footprint (separate task).
Files changed:
- Created: asset_manager_dcl.h, asset_manager_utils.h
- Modified: asset_manager.h (removed structs), asset_manager.cc
- Updated: object.h, visual_debug.h, renderer_mesh.cc,
flash_cube_effect.cc, hybrid_3d_effect.cc, test files
|
|
|
|
Updated PROJECT_CONTEXT.md and TODO.md to include new critical tasks and reflect changes in task prioritization.
Modified doc/3D.md to adjust task descriptions.
Modified doc/CONTRIBUTING.md to incorporate the new in-memory replacement rule.
Regenerated asset files (src/generated/assets.h, src/generated/assets_data.cc, src/generated/test_assets.h, src/generated/test_assets_data.cc) to reflect any changes in asset definitions.
Removed temporary changes to GEMINI.md and HANDOFF.md.
|
|
Implemented a new standalone test tool 'test_mesh' to:
- Load a .obj file specified via command line.
- Display the mesh with rotation and basic lighting on a tiled floor.
- Provide a '--debug' option to visualize vertex normals as cyan lines.
- Updated asset_packer to auto-generate smooth normals for OBJs if missing.
- Fixed various WGPU API usage inconsistencies and build issues on macOS.
- Exposed Renderer3D::GetVisualDebug() for test access.
- Added custom Vec3 struct and math utilities for OBJ parsing.
This tool helps verify mesh ingestion and normal computation independently of the main demo logic.
|
|
Moved SDF, Mesh, and Skybox logic into separate files to adhere to the 500-line file limit rule.
- src/3d/renderer_sdf.cc
- src/3d/renderer_mesh.cc
- src/3d/renderer_skybox.cc
|
|
Added support for loading and rendering OBJ meshes.
- Updated asset_packer to parse .obj files into a binary format.
- Added MeshAsset and GetMeshAsset helper to asset_manager.
- Extended Object3D with mesh_asset_id and ObjectType::MESH.
- Implemented mesh rasterization pipeline in Renderer3D.
- Added a sample cube mesh and verified in test_3d_render.
|
|
Completed Task #18-B optimization and refactoring.
- Replaced runtime branching in shader with compile-time snippet substitution in ShaderComposer.
- Added 'scene_query_bvh.wgsl' and 'scene_query_linear.wgsl' as distinct snippets.
- Refactored Renderer3D to manage two separate pipelines (with and without BVH).
- Updated ShaderComposer to support snippet substitution during composition.
- Verified both paths with test_3d_render (default and --no-bvh).
- Removed temporary shader hacks and cleaned up renderer_3d.wgsl.
|
|
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.
|
|
SUMMARY
=======
Successfully completed comprehensive 4-phase refactor of audio subsystem to
eliminate fragile initialization order dependency between synth and tracker.
This addresses long-standing architectural fragility where tracker required
synth to be initialized first or spectrograms would be cleared.
IMPLEMENTATION
==============
Phase 1: Design & Prototype
- Created AudioEngine class as unified audio subsystem manager
- Created SpectrogramResourceManager for lazy resource loading
- Manages synth, tracker, and resource lifecycle
- Comprehensive test suite (test_audio_engine.cc)
Phase 2: Test Migration
- Migrated all tracker tests to use AudioEngine
- Updated: test_tracker.cc, test_tracker_timing.cc,
test_variable_tempo.cc, test_wav_dump.cc
- Pattern: Replace synth_init() + tracker_init() with engine.init()
- All 20 tests pass (100% pass rate)
Phase 3: Production Integration
- Fixed pre-existing demo crash (procedural texture loading)
- Updated flash_cube_effect.cc and hybrid_3d_effect.cc
- Migrated main.cc to use AudioEngine
- Replaced tracker_update() calls with engine.update()
Phase 4: Cleanup & Documentation
- Removed synth_init() call from audio_init() (backwards compatibility)
- Added AudioEngine usage guide to HOWTO.md
- Added audio initialization protocols to CONTRIBUTING.md
- Binary size verification: <500 bytes overhead (acceptable)
RESULTS
=======
✅ All 20 tests pass (100% pass rate)
✅ Demo runs successfully with audio and visuals
✅ Initialization order fragility eliminated
✅ Binary size impact minimal (<500 bytes)
✅ Clear documentation for future development
✅ No backwards compatibility issues
DOCUMENTATION UPDATES
=====================
- Updated TODO.md: Moved Task #56 to "Recently Completed"
- Updated PROJECT_CONTEXT.md: Added AudioEngine milestone
- Updated HOWTO.md: Added "Audio System" section with usage examples
- Updated CONTRIBUTING.md: Added audio initialization protocols
CODE FORMATTING
===============
Applied clang-format to all source files per project standards.
FILES CREATED
=============
- src/audio/audio_engine.h (new)
- src/audio/audio_engine.cc (new)
- src/audio/spectrogram_resource_manager.h (new)
- src/audio/spectrogram_resource_manager.cc (new)
- src/tests/test_audio_engine.cc (new)
KEY FILES MODIFIED
==================
- src/main.cc (migrated to AudioEngine)
- src/audio/audio.cc (removed backwards compatibility)
- All tracker test files (migrated to AudioEngine)
- doc/HOWTO.md (added usage guide)
- doc/CONTRIBUTING.md (added protocols)
- TODO.md (marked complete)
- PROJECT_CONTEXT.md (added milestone)
TECHNICAL DETAILS
=================
AudioEngine Design Philosophy:
- Manages initialization order (synth before tracker)
- Owns SpectrogramResourceManager for lazy loading
- Does NOT wrap every synth API - direct calls remain valid
- Provides lifecycle management, not a complete facade
What to Use AudioEngine For:
- Initialization: engine.init() instead of separate init calls
- Updates: engine.update(music_time) instead of tracker_update()
- Cleanup: engine.shutdown() for proper teardown
- Seeking: engine.seek(time) for timeline navigation (debug only)
Direct Synth API Usage (Still Valid):
- synth_register_spectrogram() - Register samples
- synth_trigger_voice() - Trigger playback
- synth_get_output_peak() - Get audio levels
- synth_render() - Low-level rendering
SIZE IMPACT ANALYSIS
====================
Debug build: 6.2MB
Size-optimized build: 5.0MB
Stripped build: 5.0MB
AudioEngine overhead: <500 bytes (0.01% of total)
BACKWARD COMPATIBILITY
======================
No breaking changes. Tests that need low-level control can still call
synth_init() directly. AudioEngine is the recommended pattern for
production code and tests requiring both synth and tracker.
handoff(Claude): Task #56 COMPLETE - All 4 phases finished. Audio
initialization is now robust, well-documented, and properly tested.
The fragile initialization order dependency has been eliminated.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
Completed Task #49.
- Implemented CPU-side SDF library (sphere, box, torus, plane).
- Implemented Dynamic BVH construction (rebuilt every frame).
- Implemented PhysicsSystem with semi-implicit Euler integration and collision resolution.
- Added visual debugging for BVH nodes.
- Created test_3d_physics interactive test and test_physics unit tests.
- Updated project docs and triaged new tasks.
|
|
#50)
- 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.
|
|
architecture
- Fixed black screen by ensuring clear operations in Pass 2 when Skybox pass is skipped.
- Resolved WebGPU validation errors by synchronizing depth-stencil state.
- Implemented rotating skybox using world-space ray unprojection (inv_view_proj).
- Improved procedural noise generation (multi-octave Value Noise).
- Restored scene integrity by correcting object indexing and removing artifacts.
- Updated documentation (TODO.md, PROJECT_CONTEXT.md).
|
|
- Adjusted and for both the skybox and object rendering passes in .
- The skybox pass now clears the depth buffer to 1.0 and stores this cleared value.
- The object pass correctly loads this pre-cleared depth, ensuring proper depth testing for all scene objects.
- Verified fix in , confirming both skybox and objects are visible and correctly depth-sorted.
handoff(Gemini): The rendering pipeline now correctly handles depth for two-pass rendering, with the skybox as background and objects properly visible and depth-tested.
|
|
- Implemented a two-pass rendering strategy in Renderer3D::render:
- First pass renders the skybox without depth writes.
- Second pass renders scene objects with proper depth testing.
- Ensured skybox pipeline explicitly ignores depth via .
- Corrected struct in C++ and WGSL for and padding, resolving validation errors.
- Reverted to for SDF misses, preventing sky bleed-through.
- Updated to include a SKYBOX object with Perlin noise.
handoff(Gemini): Resolved rendering bugs. Skybox renders correctly as background, and scene objects (including floor) are now visible. Codebase stable.
|
|
- Added ObjectType::SKYBOX for dedicated skybox rendering.
- Created assets/final/shaders/skybox.wgsl for background rendering.
- Implemented a two-pass rendering strategy in Renderer3D::render:
- First pass renders the skybox without depth writes.
- Second pass renders scene objects with depth testing.
- Corrected GlobalUniforms struct in common_uniforms.wgsl and src/3d/renderer.h to include and explicit padding for 112-byte alignment.
- Updated Renderer3D::update_uniforms to set the new and zero-initialize padding.
- Reverted sky sampling logic in renderer_3d.wgsl to for SDF misses, preventing background bleed-through.
- Updated test_3d_render.cc to include a SKYBOX object with Perlin noise.
handoff(Gemini): The skybox is now correctly rendered with Perlin noise as a dedicated background pass. Objects render correctly without transparency to the sky. All necessary C++ and WGSL shader changes are implemented and verified.
|
|
- Updated ProcGenFunc signature to return bool for error reporting.
- Implemented gen_perlin (Fractional Brownian Motion) in procedural/generator.cc.
- Added support for sky texture in Renderer3D and its shader.
- Integrated Perlin noise sky texture in test_3d_render.cc.
- Caught and handled memory/generation errors in AssetManager and TextureManager.
- Assigned reference numbers to all remaining tasks in documentation.
handoff(Gemini): Side-quest complete. ProcGenFunc now returns bool. Perlin noise added and used for sky in 3D test. Windows build remains stable. All tasks numbered.
|
|
Extracted all hardcoded WGSL shaders into external assets. Updated AssetManager to handle shader snippets. Refactored Renderer3D, VisualDebug, and Effects to load shaders via the AssetManager, enabling better shader management and composition.
|
|
- Reverted floor to BOX (SDF) for robust shadow receipt.
- Updated shader to apply grid pattern ONLY to instance 0 (floor) or PLANE objects.
- Restored noise-based texturing for floating cubes and other SDF primitives.
- Verified that shadows and textures are now correctly applied across all scene elements.
|
|
- Switched floor back to PLANE type in test_3d_render.
- Updated fragment shader to apply grid pattern ONLY to PLANE objects.
- Restored noise-based bump mapping and texturing for BOX and other SDF primitives.
- Verified correct visual appearance of floating cubes (no fixed grid).
|
|
- Corrected world-space position calculation in SDF fragment shader.
- Transformed local hit point back to world space using the model matrix.
- Restored accurate planar p.xz mapping for the floor grid.
|
|
- Added Ray-Box intersection in local space to derive precise t_entry and t_exit.
- Optimized fragment shader to only march between box intersection points.
- Improved robustness of SDF rendering for non-uniform scaled objects.
- Verified correct texturing and shadow casting on all primitives.
|
|
- Adjusted Torus proxy hull in vs_main to 1.5x0.5x1.5 for better SDF fit.
- Updated VisualDebug::add_box to use per-object local extents.
- Standardized floor grid mapping in fs_main using planar p.xz projection.
- Verified non-uniform scale and rotation robustness in test_3d_render.
|
|
|
|
- Implemented planar (p.xz) grid mapping for BOX objects in the SDF path.
- Standardized grid generation logic between raster and SDF paths for consistency.
- Ensured grid is high-contrast and clearly visible on the floor.
|
|
- Adjusted Torus proxy hull in vs_main to fit unit dimensions (1.4x0.4x1.4).
- Updated VisualDebug to support per-object local extents, improving wireframe accuracy.
- Restored procedural floor grid and SDF bump mapping in the fragment shader.
- Added varied scaling to test scene objects to verify transform robustness.
|
|
- Updated VisualDebug to accept mat4 transforms, enabling wireframes to follow rotating objects.
- Restored SDF bump mapping and floor grid texture in the fragment shader.
- Added vec4::xyz() helper to mini_math.h.
- Fixed Renderer3D to pass the full model matrix for debug visualization.
|
|
- Updated ObjectData to include inv_model for reliable world-to-local mapping.
- Enabled SDF raymarching path for all objects in test_3d_render (floor is now a large SDF BOX).
- Implemented robust normal calculation using SDF gradient for all objects.
- Standardized lighting (light_dir = 1,1,1) and diffuse+ambient model.
- Refined calc_shadow with instance-based skip_idx and robust bias.
- Fixed non-uniform scale handling in shader by extracting min scale from model matrix.
|
|
- Converted floor in test_3d_render to a large SDF BOX for consistent shading.
- Standardized lighting (light_dir = 1,1,1) and normal calculation for all objects.
- Fixed calc_shadow bias and skip_idx to reliably prevent self-shadowing.
- Improved raymarching robustness in fs_main to find exact SDF hit points.
|
|
- Elevated objects in test_3d_render to avoid shadow occlusion.
- Slanted light direction for more visible, elongated shadows.
- Sharpened shadows by increasing k constant to 32.
- Cleaned up debug printfs from previous turns.
- Maintained skip_idx logic for robust self-shadowing prevention.
|
|
- Reverted floor to CUBE (rasterized) at index 0.
- Restored vertical lighting and original soft shadow loop (k=8, t+=h).
- Maintained instance-based skip_idx for generic self-shadowing prevention.
- Confirmed map_scene correctly skips the floor, allowing other objects to cast shadows on it.
|
|
- Switched floor from rasterized CUBE to SDF PLANE for consistent shadow mapping.
- Implemented skip_idx in map_scene to properly prevent self-shadowing.
- Standardized soft shadow logic with improved bias and step size.
- Increased object elevation and adjusted light direction for more visible shadows.
- Enabled debug boxes in test_3d_render.
|
|
- Implemented dynamic resolution support in all shaders and effects.
- Added explicit viewport setting for all render passes to ensure correct scaling.
- Fixed 3D shadow mapping by adding PLANE support and standardizing soft shadow logic.
- Propagated resize events through the Effect hierarchy.
- Applied project-wide code formatting.
|
|
- Replaced invalid 'i++' with 'i = i + 1' in the shader's calc_shadow function loop.
- This resolves the shader parsing error and allows the 3D renderer test to run successfully on all platforms.
|
|
- Modified 'test_3d_render' to generate and use a procedural 'grid' texture for the floor.
- Updated fragment shader to sample the texture for rasterized objects, adding a grid pattern to the floor.
- This provides visual detail and contrast, making raymarched shadows much easier to observe and verify.
|
|
- Removed duplicate 'light_dir' declaration in the shader.
- Fixed a syntax error (duplicate closing raw string delimiter) that caused shader compilation failure.
- Verified all targets build and run correctly with 'check_all.sh'.
|
|
- Fixed 'redefinition of light_dir' shader validation error by centralizing the light definition at the top of fs_main.
- Further brightened the floor in 'test_3d_render' for better shadow contrast.
- Reduced shadow bias and made the light more vertical to ensure shadows are clearly visible on all surfaces.
|
|
- Part 1: Unified shadow calculation in fragment shader for both SDF and rasterized objects.
- Part 2: Added 'model_inverse_transpose' to ObjectData to correctly transform normals for non-uniformly scaled objects.
- Part 3: Brightened the floor in 'test_3d_render' to make shadows visible.
- Verified correct lighting and shadows on the non-uniformly scaled floor.
|
|
- Implemented full support for non-uniform scaling by calculating and passing the 'model_inverse_transpose' matrix to the shader for correct normal transformation.
- Added 'transpose()' and 'inverse()' methods to the 'mat4' class in 'mini_math.h'.
- Refactored the shader to use the new matrix for lighting rasterized objects.
- Updated the test scene to use a rasterized floor (CUBE) instead of an SDF one, ensuring it receives correct lighting and shadows even with non-uniform scale.
|
|
- Refactored the fragment shader to calculate raymarched shadows for all fragments, not just SDF objects.
- This enables rasterized objects (like the floor) to receive shadows from SDF objects, fixing the missing shadows in the test scene.
- This serves as a proof-of-concept for a unified lighting pipeline.
|
|
- Updated Renderer3D shader to include 'map_scene' and 'calc_shadow' functions.
- Shader now iterates over all objects (up to kMaxObjects) to evaluate the scene SDF globally.
- Implemented hard/soft shadows from a fixed directional light.
- Updated GlobalUniforms struct with proper packing/padding for WebGPU compatibility.
- Captured 'GPU BVH & Shadows' task in PROJECT_CONTEXT.md for future optimization.
|
|
- Added 'src/3d/visual_debug.h/cc' to implement wireframe rendering.
- Integrated VisualDebug into Renderer3D with a static global toggle.
- Added '--debug' command-line option to 'demo64k' and 'test_3d_render' to enable wireframes.
- Updated 'src/gpu/effects/hybrid_3d_effect.h' to expose the debug setter (reverted later as static method used).
- Ensured full cross-platform compatibility (native and Windows) for the new debug module.
- All code guarded by STRIP_ALL for final release.
|
|
- Fixed test_sequence by restoring MainSequence::init_test for mocking.
- Corrected CMakeLists.txt dependencies and source groupings to prevent duplicate symbols.
- standardizing Effect constructor signature for seq_compiler compatibility.
- Implemented Hybrid3DEffect using bumpy Renderer3D and procedural NOISE_TEX.
- Updated MainSequence to support depth buffer for 3D elements.
- Formatted all source files with clang-format.
|
|
- Added depth buffer support to MainSequence.
- Implemented Hybrid3DEffect for the main timeline.
- Fixed effect initialization order in MainSequence.
- Ensured depth-stencil compatibility for all scene effects.
- Updated demo sequence with 3D elements and post-processing.
|
|
- Updated asset_packer to correctly parse PROC(...) syntax using regex, handling nested commas.
- Implemented runtime dispatch in AssetManager for procedural generation with dynamic memory management.
- Added procedural generator functions (noise, grid, periodic).
- Added comprehensive tests for procedural asset lifecycle (generation, caching, invalidation).
- Fixed C++ string literal escaping in asset_packer.
|
|
- Replaced white noise with smooth value-like noise.
- Implemented periodic texture generation (seam blending).
- Integrated bump mapping into Renderer3D using finite difference of displaced SDF.
- Updated test_3d_render with noise texture and multiple SDF shapes (Box, Sphere, Torus).
|
|
- Added SDF logic for Sphere, Box, and Torus in WGSL.
- Implemented hybrid normal calculation (analytical for sphere, numerical fallback).
- Updated Renderer3D to dispatch object types to shader.
- Updated test_3d_render to display mixed SDF shapes (Sphere, Torus, Box).
- Added BOX to ObjectType enum.
|
|
- Extended mini_math.h with mat4 multiplication and affine transforms.
- Implemented TextureManager for runtime procedural texture generation and GPU upload.
- Added 3D system components: Camera, Object, Scene, and Renderer3D.
- Created test_3d_render mini-demo for interactive 3D verification.
- Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny.
|