use glam::Vec3;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DirectionalLight {
pub direction: Vec3,
pub color: [f32; 3],
pub illuminance: f32,
pub shadow: Option<DirectionalShadow>,
pub fog_energy: f32,
pub shadow_opacity: f32,
pub angular_diameter: f32,
}
impl DirectionalLight {
pub const SUN_ANGULAR_DIAMETER: f32 = 0.53 * std::f32::consts::PI / 180.;
}
impl Default for DirectionalLight {
fn default() -> Self {
Self {
direction: Vec3::NEG_Z,
color: [1.; 3],
illuminance: std::f32::consts::PI,
shadow: None,
fog_energy: 1.,
shadow_opacity: 1.,
angular_diameter: Self::SUN_ANGULAR_DIAMETER,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct DirectionalShadow {
pub distance: f32,
pub cascades: u32,
}
impl DirectionalShadow {
pub const DEFAULT: Self = Self {
distance: 150.,
cascades: 4,
};
}
impl Default for DirectionalShadow {
fn default() -> Self {
Self::DEFAULT
}
}
impl DirectionalLight {
pub(crate) fn is_on(&self) -> bool {
self.illuminance > 0. && self.direction.try_normalize().is_some()
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct HemisphereLight {
pub sky_color: [f32; 3],
pub ground_color: [f32; 3],
pub intensity: f32,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct EnvironmentLight {
pub yaw: f32,
pub intensity: f32,
}
impl Default for EnvironmentLight {
fn default() -> Self {
Self {
yaw: 0.,
intensity: 1.,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Backdrop {
Environment { yaw: f32, brightness: f32 },
Color([f32; 3]),
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Mist {
pub thin_color: [f32; 3],
pub dense_color: [f32; 3],
pub opacity: f32,
pub width: f32,
pub height: f32,
pub drift: [f32; 2],
}
impl Default for Mist {
fn default() -> Self {
Self {
thin_color: [0.; 3],
dense_color: [0.; 3],
opacity: 0.,
width: 1.,
height: 1.,
drift: [-0.025 / 7., 0.035 / 3.],
}
}
}