summaryrefslogtreecommitdiff
path: root/src/tests/test_mesh.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-06 09:46:57 +0100
committerskal <pascal.massimino@gmail.com>2026-02-06 09:46:57 +0100
commitb2bd45885a77e8936ab1d2c2ed30a238d9f073a6 (patch)
tree169608a9a88e4d009639b25089cdac785036b7b4 /src/tests/test_mesh.cc
parentf573e9e12855f9a90878c57d1083985dc29d75b5 (diff)
fix(test_mesh): Use uniform floor scale to fix shadow artifacts
Fixed floor shadow stretching caused by extreme non-uniform scaling. ROOT CAUSE: Floor plane used scale(20.0, 0.01, 20.0) - a 2000:1 scale ratio! When transforming shadow ray points into local space: - Y coordinates scaled by 1/0.01 = 100x - sdPlane distance calculation returns distorted values - Shadow raymarching fails, causing stretching artifacts ISSUE: floor.scale = vec3(20.0f, 0.01f, 20.0f); // ❌ Extreme non-uniform scale // In local space: dot(p_local, (0,1,0)) + 0.0 // But p_local.y is 100x larger than world-space distance! FIX: floor.scale = vec3(1.0f, 1.0f, 1.0f); // ✓ Uniform scale floor.position = vec3(0, 0, 0); // Explicit ground level EXPLANATION: For PLANE objects, XZ scale doesn't matter (planes are infinite). Y scale distorts the SDF distance calculation. Uniform scale preserves correct world-space distances. RESULT: - Floor shadows now render correctly - No stretching toward center - Shadow distances accurate for soft shadow calculations COMBINED WITH PREVIOUS FIXES: 1. Shader normal transformation (double-transpose fix) 2. Quaternion axis normalization (rotation stretching fix) 3. Mesh shadow scaling exclusion (AABB size fix) 4. Floor uniform scale (this fix) Task A (test_mesh visualization) now FULLY RESOLVED. handoff(Claude): All mesh transformation and shadow bugs fixed. Meshes rotate correctly, normals transform properly, shadows render accurately. Remaining known limitation: mesh shadows use AABB (axis-aligned), so they don't rotate with the mesh - this is expected AABB behavior.
Diffstat (limited to 'src/tests/test_mesh.cc')
-rw-r--r--src/tests/test_mesh.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tests/test_mesh.cc b/src/tests/test_mesh.cc
index f29ec27..75b45ac 100644
--- a/src/tests/test_mesh.cc
+++ b/src/tests/test_mesh.cc
@@ -284,7 +284,8 @@ int main(int argc, char** argv) {
// --- Create Scene ---
Object3D floor(ObjectType::PLANE);
- floor.scale = vec3(20.0f, 0.01f, 20.0f); // Very thin floor proxy
+ floor.position = vec3(0, 0, 0); // Floor at ground level
+ floor.scale = vec3(1.0f, 1.0f, 1.0f); // Uniform scale (planes are infinite anyway)
floor.color = vec4(0.5f, 0.5f, 0.5f, 1.0f);
g_scene.add_object(floor);