aboutsummaryrefslogtreecommitdiff
path: root/src/material/reflectant.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-08-05 15:44:40 +0200
committerJulian T <julian@jtle.dk>2021-08-05 15:44:40 +0200
commit3ef8f4d918406eec6bdc29e0ebd883fabfac9b2e (patch)
treeaa4b1aac1e165821c16f222ebfb9212a9740e98b /src/material/reflectant.rs
parent45119506c0293fdde6cef35f6e6f82d4055b46b6 (diff)
Add picture for c5505ab84820248c6dba35fc06aef9e0ced183derendered
Diffstat (limited to 'src/material/reflectant.rs')
-rw-r--r--src/material/reflectant.rs40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/material/reflectant.rs b/src/material/reflectant.rs
deleted file mode 100644
index b5ec0ae..0000000
--- a/src/material/reflectant.rs
+++ /dev/null
@@ -1,40 +0,0 @@
-use crate::Float;
-use crate::core::{Ray, Spectrum, Vector3f};
-use crate::world::Intersection;
-use super::Material;
-use crate::sample::Sampler;
-
-pub struct Reflectant {
- color: Spectrum,
- fuzz: Option<Float>,
-}
-
-impl Reflectant {
- pub fn new(c: Spectrum, fuzz: Option<Float>) -> Reflectant {
- Reflectant {
- color: c,
- fuzz,
- }
- }
-}
-
-pub fn reflect(v: Vector3f, n: Vector3f) -> Vector3f {
- v - n * (2.0 * v.dot(&n))
-}
-
-impl Material for Reflectant {
- fn scatter(&self, ray: &Ray, i: &Intersection, sampler: &mut dyn Sampler) -> Option<(Spectrum, Ray)> {
- // Find reflectance vector
- let mut reflected = reflect(ray.direction, i.n);
- if let Some(fuzz) = self.fuzz {
- reflected += &(sampler.get_unit_vector() * fuzz);
- }
-
- Some((
- self.color,
- Ray::new(i.p, reflected.norm()),
- ))
- }
-}
-
-