summaryrefslogtreecommitdiff
path: root/engine/src/lighting.rs
blob: bfc2d9b1806426da88b355d3ba419ef498ba6cc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use ecs::{Component, Sole};

use crate::color::Color;
use crate::util::builder;

builder! {
#[builder(name = PointLightBuilder, derives = (Debug, Clone))]
#[derive(Debug, Clone, Component)]
#[non_exhaustive]
pub struct PointLight
{
    pub diffuse: Color<f32>,
    pub specular: Color<f32>,
}
}

impl PointLight
{
    pub fn builder() -> PointLightBuilder
    {
        PointLightBuilder::default()
    }
}

impl Default for PointLight
{
    fn default() -> Self
    {
        Self {
            diffuse: Color { red: 0.5, green: 0.5, blue: 0.5 },
            specular: Color { red: 1.0, green: 1.0, blue: 1.0 },
        }
    }
}

impl Default for PointLightBuilder
{
    fn default() -> Self
    {
        PointLight::default().into()
    }
}

builder! {
/// Global light properties.
#[builder(name = GlobalLightBuilder, derives = (Debug, Clone, Default))]
#[derive(Debug, Clone, Default, Sole)]
#[non_exhaustive]
pub struct GlobalLight
{
    pub ambient: Color<f32>,
}
}

impl GlobalLight
{
    #[must_use]
    pub fn builder() -> GlobalLightBuilder
    {
        GlobalLightBuilder::default()
    }
}