mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add a few pieces of documentation to code related to light and shadows
This commit is contained in:
parent
93a565e51b
commit
be1cc1b983
@ -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<f32> {
|
||||
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<f32> {
|
||||
let angle_rad = Self::get_angle_rad(time_of_day);
|
||||
-Vec3::new(-angle_rad.sin(), 0.0, angle_rad.cos() - 0.5).normalized()
|
||||
|
@ -366,6 +366,14 @@ pub fn calc_focused_light_volume_points<T: Float + MulAdd<T, T, Output = T> + 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<T, T, Output = T>,
|
||||
|
Loading…
Reference in New Issue
Block a user