Skip to main content

engvis_core/
light.rs

1use glam::Vec3;
2
3#[derive(Debug, Clone)]
4pub struct DirectionalLight {
5    pub direction: Vec3,
6    pub color: [f32; 3],
7    pub intensity: f32,
8    pub cast_shadows: bool,
9}
10
11impl Default for DirectionalLight {
12    fn default() -> Self {
13        Self {
14            direction: Vec3::new(-0.5, -1.0, -0.3).normalize(),
15            color: [1.0, 0.98, 0.95],
16            intensity: 4.0,
17            cast_shadows: false,
18        }
19    }
20}
21
22#[derive(Debug, Clone)]
23pub struct PointLight {
24    pub position: Vec3,
25    pub color: [f32; 3],
26    pub intensity: f32,
27    pub range: f32,
28}
29
30#[derive(Debug, Clone)]
31pub struct AmbientLight {
32    pub color: [f32; 3],
33    pub intensity: f32,
34}
35
36impl Default for AmbientLight {
37    fn default() -> Self {
38        Self {
39            color: [0.4, 0.42, 0.45],
40            intensity: 0.3,
41        }
42    }
43}
44
45/// Aggregated scene lighting
46#[derive(Debug, Clone)]
47pub struct LightingEnvironment {
48    pub ambient: AmbientLight,
49    pub directional_lights: Vec<DirectionalLight>,
50    pub point_lights: Vec<PointLight>,
51}
52
53impl Default for LightingEnvironment {
54    fn default() -> Self {
55        Self {
56            ambient: AmbientLight::default(),
57            directional_lights: vec![
58                DirectionalLight::default(),
59                // Fill light from opposite side
60                DirectionalLight {
61                    direction: Vec3::new(0.6, -0.3, 0.7).normalize(),
62                    color: [0.9, 0.92, 1.0],
63                    intensity: 1.5,
64                    cast_shadows: false,
65                },
66            ],
67            point_lights: Vec::new(),
68        }
69    }
70}