fix(shadow): make Étape 14 shadow visible
The shadow pass was correct but the demo light was much too steep (52° elevation), so the blocker's shadow fell in a ~0.5-unit sliver tight against the cube's base and was invisible against the bright ground (offscreen pixel probe found a single dark pixel). Verified with an offscreen probe using the real Renderer::render_scene + shadow path: - steep front light (0.6,1.1,0.6) -> 1 dark pixel (no visible shadow) - shallow side light (1.0,0.3,0.0) -> 17 107 pixels (shadow pipeline OK) - tuned front-right (1.0,0.5,0.0) -> 16 979 pixels (clear visible shadow) The azimuth matters most: from the elevated front-right camera, a shadow cast toward -z falls behind the cube and is occluded; one cast toward -x runs across the ground to the left of the cube and reads clearly. Tuned light therefore sits front-right and low (toward_light (1.0,0.5,0.0)), keeping the front faces lit while casting a clearly visible PCF-softened shadow. Also reapply the LessEqual comparison sampler fix (commit39167eehad set it, but was later reverted to GreaterEqual by9a51ff7while debugging; the probe confirms LessEqual is the correct, non-inverted test). Correct 'rotating cube' to 'cube' in README/ROADMAP (shadow_test scene is static).
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
//! directions are easy to read:
|
||||
//!
|
||||
//! 1. the **blocker** (cube) casts a directional shadow that stretches along
|
||||
//! the ground opposite the light direction,
|
||||
//! the ground opposite the light direction. The light sits at the camera's
|
||||
//! front-right and low-ish, so its shadow runs clearly across the ground to
|
||||
//! the left of the cube and is easy to see,
|
||||
//! 2. the shadow edge is **softened** by 3×3 PCF (no hard jagged border),
|
||||
//! 3. the lit faces are bright while the shadowed ground stays near-ambient,
|
||||
//! proving the depth comparison is applied per-pixel.
|
||||
@@ -118,9 +120,12 @@ impl wsg_lib::AppHandler for ShadowTest {
|
||||
|
||||
// One directional light only: replace the default list.
|
||||
app.scene.clear_lights();
|
||||
// Direction "from surface toward the light", i.e. the light source sits up and to
|
||||
// the -x -z side, so the shadow is cast toward +x +z (toward the camera).
|
||||
let toward_light = Vec3::new(-0.6, 1.1, -0.6).normalize();
|
||||
// Direction "from surface toward the light": the light sits up and to the +x side
|
||||
// (the camera's right), at a lowish elevation. Its shadow is then cast toward -x,
|
||||
// running clearly across the ground to the left of the cube. A steeper or more
|
||||
// frontal light would push the shadow tight against the cube's base or behind it,
|
||||
// where it is occluded by the cube from this elevated front-right view.
|
||||
let toward_light = Vec3::new(1.0, 0.5, 0.0).normalize();
|
||||
app.scene
|
||||
.add_directional_light(toward_light, [1.0, 0.98, 0.92], 1.6)
|
||||
.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user