aboutsummaryrefslogtreecommitdiff
path: root/src/material/lambertian.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/material/lambertian.rs')
-rw-r--r--src/material/lambertian.rs38
1 files changed, 0 insertions, 38 deletions
diff --git a/src/material/lambertian.rs b/src/material/lambertian.rs
deleted file mode 100644
index 3df6522..0000000
--- a/src/material/lambertian.rs
+++ /dev/null
@@ -1,38 +0,0 @@
-use super::Material;
-use crate::core::{Ray, Spectrum};
-use crate::world::Intersection;
-use crate::sample::Sampler;
-
-use std::rc::Rc;
-
-pub struct Lambertian {
- color: Spectrum,
-}
-
-impl Lambertian {
- pub fn new(c: Spectrum) -> Lambertian {
- Lambertian {
- color: c,
- }
- }
-
- pub fn new_rc(c: Spectrum) -> Rc<dyn Material> {
- Rc::new(Self::new(c))
- }
-}
-
-impl Material for Lambertian {
- fn scatter(&self, _: &Ray, i: &Intersection, sampler: &mut dyn Sampler) -> Option<(Spectrum, Ray)> {
- let mut newray = Ray {
- origin: i.p,
- direction: i.n + sampler.get_unit_vector(),
- };
-
- // Make sure that the resulting direction is not (0, 0, 0)
- if newray.direction.near_zero() {
- newray.direction = i.n;
- }
-
- Some((self.color, newray))
- }
-}