Files
wsg/lib/examples
Jérôme Bousquié ab13fa725e 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 (commit 39167ee had set it,
but was later reverted to GreaterEqual by 9a51ff7 while debugging; the probe
confirms LessEqual is the correct, non-inverted test). Correct 'rotating cube'
to 'cube' in README/ROADMAP (shadow_test scene is static).
2026-09-19 21:12:25 +02:00
..

Examples

Each .rs file in this directory is a standalone example auto-discovered by Cargo (cargo build -p wsg-lib --examples). To run an example:

cargo run -p wsg-lib --example <name>
Example Command Description
simple cargo run -p wsg-lib --example simple Flat unlit quad (minimal declarative workflow, AppBuilder + auto scene).
cube cargo run -p wsg-lib --example cube Textured cube (procedural checker) lit by a directional + point + spot light.
manual cargo run -p wsg-lib --example manual Low-level workflow: Context, Renderer, PipelineCache, Mesh used directly (no App facade).
spot_test cargo run -p wsg-lib --example spot_test Spot-light isolation: only one spot is on (near-zero ambient), cube rotates on two axes so the oriented beam is clearly visible.
shadow_test cargo run -p wsg-lib --example shadow_test Shadow mapping (Étape 14): one directional light is the shadow caster (set_shadow_caster(Some(0))); a cube casts a PCF-softened shadow onto a thin ground slab.

Conventions

  • Examples are self-contained: no assets loaded from disk (procedural textures, hardcoded geometry).
  • They use the declarative workflow (AppBuilder + Scene) except manual, which bypasses the App facade.
  • When adding a new example: create a .rs file in this directory, document it here, and reference it in the root README if appropriate.