diff --git a/voxygen/src/render/pipelines/mod.rs b/voxygen/src/render/pipelines/mod.rs index fe5f1f684d..0fad8f5598 100644 --- a/voxygen/src/render/pipelines/mod.rs +++ b/voxygen/src/render/pipelines/mod.rs @@ -50,7 +50,9 @@ pub struct Globals { /// aligned. view_distance: [f32; 4], time_of_day: [f32; 4], // TODO: Make this f64. + /// Direction of sunlight. sun_dir: [f32; 4], + /// Direction of moonlight. moon_dir: [f32; 4], tick: [f32; 4], /// x, y represent the resolution of the screen; @@ -163,11 +165,13 @@ impl Globals { time_of_day as f32 * TIME_FACTOR } + /// Computes the direction of light from the sun based on the time of day. pub fn get_sun_dir(time_of_day: f64) -> Vec3 { let angle_rad = Self::get_angle_rad(time_of_day); Vec3::new(-angle_rad.sin(), 0.0, angle_rad.cos()) } + /// Computes the direction of light from the moon based on the time of day. pub fn get_moon_dir(time_of_day: f64) -> Vec3 { let angle_rad = Self::get_angle_rad(time_of_day); -Vec3::new(-angle_rad.sin(), 0.0, angle_rad.cos() - 0.5).normalized() diff --git a/voxygen/src/scene/math.rs b/voxygen/src/scene/math.rs index dcf55404e7..41c2ae6749 100644 --- a/voxygen/src/scene/math.rs +++ b/voxygen/src/scene/math.rs @@ -366,6 +366,14 @@ pub fn calc_focused_light_volume_points + co ) */ } +/// Computes an axis aligned bounding box that contains the provided points when +/// transformed into the coordinate space specificed by `mat`. +/// +/// "psr" stands for "Potential shadow receivers" since this function is used to +/// get an Aabb containing the potential points (which represent the extents of +/// the volumes of potential things that will be shadowed) that will be +/// shadowed. +/// /// NOTE: Will not yield useful results if pts is empty! pub fn fit_psr< T: Float + MulAdd,