Skip to main content

compute_shadow_cascades

Function compute_shadow_cascades 

Source
pub fn compute_shadow_cascades(
    view_proj: &DMat4,
    light_dir: [f32; 3],
    camera_distance: f64,
    config: &ShadowConfig,
) -> ComputedShadow
Expand description

Compute cascade light-space matrices from the camera frustum and light direction.

This is the core CSM algorithm: the camera frustum is split into cascade_count slices, and for each slice an orthographic projection from the light’s point of view is computed that tightly encloses the slice.

§Arguments

  • view_proj — camera view-projection matrix.
  • light_dir — unit direction toward the light source.
  • camera_distance — distance from camera to the target point (meters).
  • config — shadow configuration.

Returns a ComputedShadow with populated light matrices.