summaryrefslogtreecommitdiff
path: root/src/tests/test_3d_render.cc
AgeCommit message (Collapse)Author
37 hourshandoff(Claude): Stabilize 3D renderer with rotating skybox and two-pass ↵skal
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).
2 daysfix: Implement proper skybox rendering with Perlin noiseskal
- 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.
2 daysfeat: side-quest - Perlin noise sky and ProcGenFunc error handlingskal
- 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.
2 daysrefactor: Task #20 - Platform & Code Hygieneskal
- Consolidated all WebGPU shims and platform-specific logic into src/platform.h. - Refactored platform_init to return PlatformState by value and platform_poll to automatically refresh time and aspect_ratio. - Removed STL dependencies (std::map, std::vector, std::string) from AssetManager and Procedural subsystems. - Fixed Windows cross-compilation by adjusting include paths and linker flags in CMakeLists.txt and updating build_win.sh. - Removed redundant direct inclusions of GLFW/glfw3.h and WebGPU headers across the project. - Applied clang-format and updated documentation. handoff(Gemini): Completed Task #20 and 20.1. Platform abstraction is now unified, and core paths are STL-free. Windows build is stable.
3 daysfix: Resolve shader initialization crashes and build errorsskal
Fixes crashes in demo64k and test_3d_render caused by uninitialized ShaderComposer. Moves InitShaderComposer() call before effect initialization in gpu.cc and adds explicit call in test_3d_render.cc. Also fixes include paths for generated assets.h in multiple files.
3 daysfix(3d): Stabilize shadows and isolate floor grid textureskal
- 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.
3 daysfix(3d): Distinguish floor grid from object texturesskal
- 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).
3 daystest(3d): Enlarge objects and pack them closer to the centerskal
- Increased number of random objects to 30. - Enlarged base scale of all objects. - Restricted object distribution radius to encourage inter-object shadows. - Scaled up center torus and moving sphere.
3 daysfix(3d): Tighten torus proxy hull and ensure floor grid visibilityskal
- 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.
3 dayschore: Apply final code formatting and cleanupskal
3 daysfix(3d): Unify SDF path for all objects and stabilize shadowsskal
- 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.
3 daysfix(3d): Restore and enhance 3D shadowsskal
- 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.
3 daysfix(3d): Revert to working N-1 shadow configurationskal
- 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.
3 daysfix(3d): Resolve missing shadows on floor planeskal
- 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.
3 daysflesh out extra details in the MD filesskal
3 daysfix(gpu): Resolve high-DPI squished rendering and 3D shadow bugsskal
- 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.
3 daysfix(shader): Correct WGSL loop syntax in calc_shadowskal
- 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.
3 daystest(3d): Add procedural grid to floor and enable texturingskal
- 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.
3 daysfeat(3d): Implement unified shadow system with non-uniform scale supportskal
- 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.
3 daysfix(3d): Correct shadow bug with non-uniform scaleskal
- Changed the floor object in 'test_3d_render' from SDF BOX to rasterized CUBE. - This prevents the non-uniform scale of the floor from breaking the scene-wide SDF query used for shadow calculations. - The lighting and shadows now render correctly in the more complex test scene.
3 daystest(3d): Enhance test scene with more objectsskal
- Updated 'src/tests/test_3d_render.cc' to populate the scene with a large floor and 30 randomly placed objects (spheres, boxes, tori). - This provides a more complex environment to verify the new shadow mapping implementation.
3 daysfeat(3d): Add scaffolding for visual debugging (Task #18a)skal
- 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.
3 daysfix(build): Add compatibility for older wgpu-native headersskal
- Added preprocessor definitions for 'WGPUOptionalBool_True' and 'WGPUOptionalBool_False' to ensure successful cross-compilation against the older wgpu-native headers used for the Windows build. - This resolves the build failures in the Windows CI/check script.
4 daysrefactor(platform): Encapsulate state in PlatformState structskal
- Replaced all global static variables in the platform layer with a single PlatformState struct. - Updated all platform function signatures to accept a pointer to this struct, making the implementation stateless and more modular. - Refactored main.cc, tests, and tools to instantiate and pass the PlatformState struct. - This improves code organization and removes scattered global state.
4 daysfeat(platform): Fix high-DPI scaling and add resolution optionskal
- Fixed a 'squished' viewport bug on high-DPI (Retina) displays by querying the framebuffer size in pixels instead of using the window size in points. - Centralized window dimension management within the platform layer. - Added a '--resolution WxH' command-line option to allow specifying a custom window size at startup. This option is stripped in STRIP_ALL builds. - Updated all test and tool executables to use the new platform API.
4 daysfeat: Add seamless bump mapping with procedural noiseskal
- 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).
4 daysfeat: Implement hybrid rendering with SDF primitivesskal
- 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.
4 daysfeat: Implement 3D system and procedural texture managerskal
- 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.