c2cbd7fadb
Implement shadow mapping for directional lights: - Scene::set_shadow_caster(Option<usize>) selects the shadow-casting light by packed frame-array index (None disables; point lights rejected at render). - Lights::get(index) resolves a packed index across the directional/point/spot lists. - Renderer allocates a shadow depth map, comparison sampler, group-3 bind groups, shadow uniform buffer and shadow pipeline; render_scene does a depth-only shadow pass before the main pass; compute_shadow_light_view_proj builds an orthographic light-space frustum from the scene radius. - standard_shader: shadow_light_index/light_view_proj/shadow_params uniforms, @group(3) depth map + comparison sampler, 3x3 PCF compute_shadow(). - shadow_shader: path/vertex shader with attribute layout matching the shared vertex buffer (only position consumed). - shadow_test example: directional shadow caster casts a PCF-softened shadow onto a ground slab; documented in examples README.
1.5 KiB
1.5 KiB
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) exceptmanual, which bypasses theAppfacade. - When adding a new example: create a
.rsfile in this directory, document it here, and reference it in the root README if appropriate.