diff options
author | HampusM <hampus@hampusmat.com> | 2024-05-22 20:39:26 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-05-22 20:39:26 +0200 |
commit | d4b61dd34b06119e87c8932ab7718d432dbc6a4f (patch) | |
tree | 2240158176c11eac545a1b50bbe644700b67ab51 /engine/src/lighting.rs | |
parent | 8398025d7927564637e1ea67234665571dc7bcc5 (diff) |
feat(engine): add point light attenuation
Diffstat (limited to 'engine/src/lighting.rs')
-rw-r--r-- | engine/src/lighting.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/engine/src/lighting.rs b/engine/src/lighting.rs index bfc2d9b..ffa2645 100644 --- a/engine/src/lighting.rs +++ b/engine/src/lighting.rs @@ -11,6 +11,7 @@ pub struct PointLight { pub diffuse: Color<f32>, pub specular: Color<f32>, + pub attenuation_params: AttenuationParams, } } @@ -29,6 +30,7 @@ impl Default for PointLight Self { diffuse: Color { red: 0.5, green: 0.5, blue: 0.5 }, specular: Color { red: 1.0, green: 1.0, blue: 1.0 }, + attenuation_params: AttenuationParams::default(), } } } @@ -41,6 +43,27 @@ impl Default for PointLightBuilder } } +/// Parameters for light [attenuation](https://en.wikipedia.org/wiki/Attenuation). +#[derive(Debug, Clone)] +pub struct AttenuationParams +{ + pub constant: f32, + pub linear: f32, + pub quadratic: f32, +} + +impl Default for AttenuationParams +{ + fn default() -> Self + { + Self { + constant: 1.0, + linear: 0.0, + quadratic: 0.0, + } + } +} + builder! { /// Global light properties. #[builder(name = GlobalLightBuilder, derives = (Debug, Clone, Default))] |