diff --git a/pathtracer/src/light/ambient_light.rs b/pathtracer/src/light/ambient_light.rs index 6e8a75f..708dd92 100644 --- a/pathtracer/src/light/ambient_light.rs +++ b/pathtracer/src/light/ambient_light.rs @@ -27,6 +27,10 @@ impl AmbientLight { impl Light for AmbientLight { fn illumination(&self, _: &Point) -> LinearColor { + self.luminance() + } + + fn luminance(&self) -> LinearColor { self.color.clone() } } diff --git a/pathtracer/src/light/directional_light.rs b/pathtracer/src/light/directional_light.rs index b40d153..512c2d1 100644 --- a/pathtracer/src/light/directional_light.rs +++ b/pathtracer/src/light/directional_light.rs @@ -34,6 +34,10 @@ impl DirectionalLight { impl Light for DirectionalLight { fn illumination(&self, _: &Point) -> LinearColor { + self.luminance() + } + + fn luminance(&self) -> LinearColor { self.color.clone() } } diff --git a/pathtracer/src/light/mod.rs b/pathtracer/src/light/mod.rs index e7e68a5..2aa3607 100644 --- a/pathtracer/src/light/mod.rs +++ b/pathtracer/src/light/mod.rs @@ -9,6 +9,9 @@ use nalgebra::Unit; pub trait Light: std::fmt::Debug { /// Get the illumination of that light on that point. fn illumination(&self, point: &Point) -> LinearColor; + + /// Get the raw luminance of that light + fn luminance(&self) -> LinearColor; } /// Represent a light which has an abstract position in the scene being rendered. diff --git a/pathtracer/src/light/point_light.rs b/pathtracer/src/light/point_light.rs index a26863b..1dd2ced 100644 --- a/pathtracer/src/light/point_light.rs +++ b/pathtracer/src/light/point_light.rs @@ -36,7 +36,11 @@ impl PointLight { impl Light for PointLight { fn illumination(&self, point: &Point) -> LinearColor { let dist = (self.position - point).norm(); - self.color.clone() / dist + self.luminance() / dist + } + + fn luminance(&self) -> LinearColor { + self.color.clone() } } diff --git a/pathtracer/src/light/spot_light.rs b/pathtracer/src/light/spot_light.rs index 1526071..faa2c97 100644 --- a/pathtracer/src/light/spot_light.rs +++ b/pathtracer/src/light/spot_light.rs @@ -54,11 +54,15 @@ impl Light for SpotLight { let delt = point - self.position; let cos = self.direction.dot(&delt.normalize()); if cos >= self.cosine_value { - self.color.clone() / delt.norm_squared() + self.luminance() / delt.norm_squared() } else { LinearColor::black() } } + + fn luminance(&self) -> LinearColor { + self.color.clone() + } } impl SpatialLight for SpotLight {