diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-02 14:00:16 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-02 14:00:16 +0100 |
| commit | a5409a168d08552c0fc0ad2cff8a9f32199272a1 (patch) | |
| tree | 86a6d8890c688c4c6ea6cc3f274edc784e85876a /src/3d | |
| parent | 844f5d32f37877bf65e72bcfb994d39b713a7317 (diff) | |
feat(3d): Implement unified shadow system with non-uniform scale support
- 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.
Diffstat (limited to 'src/3d')
| -rw-r--r-- | src/3d/renderer.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/3d/renderer.cc b/src/3d/renderer.cc index b655588..3280df7 100644 --- a/src/3d/renderer.cc +++ b/src/3d/renderer.cc @@ -222,7 +222,9 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> { normal = normalize(mat3 * n_local); } - let shadow = calc_shadow(p + normal * 0.05, light_dir, 0.0, 20.0); + let light_dir = normalize(vec3<f32>(0.2, 1.0, 0.2)); // More vertical light for easier shadow debugging + let shadow = calc_shadow(p + normal * 0.01, light_dir, 0.0, 20.0); + let lighting = (max(dot(normal, light_dir), 0.0) * shadow) + 0.1; return vec4<f32>(in.color.rgb * lighting, 1.0); } |
