| Age | Commit message (Collapse) | Author |
|
Fixed three critical WGSL shader issues causing demo64k and test_3d_render to crash:
1. **renderer_3d.wgsl**: Removed dead code using non-existent `inverse()` function
- WGSL doesn't have `inverse()` for matrices
- Dead code was unreachable but still validated by shader compiler
- Also removed reference to undefined `in.normal` vertex input
2. **sdf_utils.wgsl & lighting.wgsl**: Fixed `get_normal_basic()` signature mismatch
- Changed parameter from `obj_type: f32` to `obj_params: vec4<f32>`
- Now correctly matches `get_dist()` function signature
3. **scene_query_linear.wgsl**: Fixed incorrect BVH binding declaration
- Linear mode was incorrectly declaring binding 2 (BVH buffer)
- Replaced BVH traversal with simple linear object loop
- Root cause: Both BVH and Linear shaders were identical (copy-paste error)
Added comprehensive shader compilation test (test_shader_compilation.cc):
- Tests all production shaders compile successfully through WebGPU
- Validates both BVH and Linear composition modes
- Catches WGSL syntax errors, binding mismatches, and type errors
- Would have caught all three bugs fixed in this commit
Why tests didn't catch this:
- Existing test_shader_assets only checked for keywords, not compilation
- No test actually created WebGPU shader modules from composed code
- New test fills this gap with real GPU validation
Results:
- demo64k runs without WebGPU errors
- test_3d_render no longer crashes
- All 22/23 tests pass (FftTest unrelated issue from FFT Phase 1)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
|
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).
|
|
|
|
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.
|