From 94b14ec5a24f587c97b11d6c56b9116a58a7385a Mon Sep 17 00:00:00 2001 From: Julian T Date: Sun, 7 Mar 2021 18:25:35 +0100 Subject: Add light materials --- src/material/diffuse_light.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/material/diffuse_light.rs (limited to 'src/material/diffuse_light.rs') diff --git a/src/material/diffuse_light.rs b/src/material/diffuse_light.rs new file mode 100644 index 0000000..fe462a8 --- /dev/null +++ b/src/material/diffuse_light.rs @@ -0,0 +1,27 @@ +use super::Material; +use crate::core::{Ray, Spectrum}; +use crate::Float; + +pub struct DiffuseLight { + color: Spectrum, +} + +impl DiffuseLight { + pub fn new(c: Spectrum) -> Self { + Self { + color: c, + } + } + + pub fn new_white(s: Float) -> Self { + Self { + color: Spectrum::new_rgb(s, s, s), + } + } +} + +impl Material for DiffuseLight { + fn emitted(&self, _: &Ray) -> Option { + Some(self.color) + } +} -- cgit v1.2.3