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.
21 lines
945 B
Rust
21 lines
945 B
Rust
//! # Utils Module — Configuration and Error Handling
|
|
//!
|
|
//! Defines two leaf concepts: **conf** (shared constants for shader paths and embedded WGSL source) and
|
|
//! **error** (WsgError, the application-level error type mapping wgpu failure modes to user-friendly messages).
|
|
//! Both are consumed by other modules but have no internal dependencies on them.
|
|
//!
|
|
//! ## Interaction with Other Modules
|
|
//! - `pipeline_cache` loads shaders from disk using conf::STANDARD_SHADER_PATH; falls back to STANDARD_SHADER.
|
|
//! - `context` returns WsgError variants from all fallible methods (new, configure, begin_frame).
|
|
//! - `renderer` does not use errors directly (panics on invalid state rather than returning Result).
|
|
|
|
pub mod conf;
|
|
pub mod error;
|
|
|
|
// Re-exports
|
|
pub use conf::{
|
|
SHADOW_MAP_SIZE, SHADOW_SCENE_CENTER, SHADOW_SCENE_RADIUS, SHADOW_SHADER, SHADOW_SHADER_PATH,
|
|
STANDARD_SHADER, STANDARD_SHADER_PATH,
|
|
};
|
|
pub use error::WsgError;
|