| Age | Commit message (Collapse) | Author |
|
This reverts commit a5229022b0e500ac86560e585081f45293e587d2.
|
|
When a plane has non-uniform scaling (e.g., floor with scale 20,0.01,20),
transforming points to local space distorts SDF distances. For a horizontal
plane with Y-scale of 0.01, distances become 100x too large in local space.
Fix: Multiply plane distances by the scale factor along the normal direction
(Y component for horizontal planes). This corrects shadow calculations while
maintaining the large floor area needed for visualization.
Reverted incorrect uniform scale fix (c23f3b9) that made floor too small.
|
|
Fixed incorrect mesh shadow rendering caused by applying scale factor to
mesh AABBs which already have correct local-space extents.
ROOT CAUSE:
The 's' scale factor (line 44) is meant for UNIT primitives (sphere,
box, torus) that are scaled by the model matrix. Meshes (type 5.0)
already store their correct AABB extents in obj_params.yzw, so applying
's' caused incorrect shadow sizes.
ISSUE:
let s = min(length(obj.model[0].xyz), ...);
if (obj.params.x != 4.0) { // Excluded planes only
d = min(d, get_dist(q, obj.params) * s); // ❌ WRONG for meshes!
}
FIX:
if (obj.params.x != 4.0 && obj.params.x != 5.0) { // Exclude planes AND meshes
d = min(d, get_dist(q, obj.params) * s);
} else {
d = min(d, get_dist(q, obj.params)); // No scaling
}
EXPLANATION:
- Type 1.0 (Sphere): Unit sphere, scaled by 's' ✓
- Type 2.0 (Box): Unit box, scaled by 's' ✓
- Type 3.0 (Torus): Unit torus, scaled by 's' ✓
- Type 4.0 (Plane): Special case, no scaling ✓
- Type 5.0 (Mesh): AABB already has correct size, no scaling needed ✓
FILES FIXED:
- assets/final/shaders/render/scene_query_linear.wgsl
- assets/final/shaders/render/scene_query_bvh.wgsl
PARTIAL FIX:
This fixes mesh shadow sizing issues. Shadow rotation limitation remains
(AABBs are axis-aligned, don't rotate with mesh - this is a fundamental
AABB limitation, not a bug).
handoff(Claude): Mesh shadows now correctly sized. Investigating floor
shadow stretching issue next (likely related to plane scaling).
|
|
|
|
Removed obsolete scene_query.wgsl (replaced by variants). Updated TODO.md. Committed generated asset files reflecting new shader snippets.
|
|
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.
|
|
#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.
|