diff --git a/lib/src/core/renderer.rs b/lib/src/core/renderer.rs index 1d2181d..ca084d8 100644 --- a/lib/src/core/renderer.rs +++ b/lib/src/core/renderer.rs @@ -336,9 +336,18 @@ impl Renderer { let light = lights.get(index)?; // Directional and spot lights carry a direction; point lights would need a 6-face cubemap // shadow, which is out of scope (D6), so we reject them. + // Directional lights carry their direction in `position_dir.xyz` (from the surface toward + // the light, see `directional_light`/shader); `dir_angle` is zero for them. Spot lights + // carry the cone axis (from the light toward the scene) in `dir_angle.xyz`. The shadow + // camera must look along the light's **travel direction** (light → scene), i.e. the negation + // of the surface→light vector for directional lights. let dir = match light.light_type() { - crate::resources::LightType::Directional - | crate::resources::LightType::Spot { .. } => Vec3::new( + crate::resources::LightType::Directional => Vec3::new( + -light.position_dir.x, + -light.position_dir.y, + -light.position_dir.z, + ), + crate::resources::LightType::Spot { .. } => Vec3::new( light.dir_angle.x, light.dir_angle.y, light.dir_angle.z,