aboutsummaryrefslogtreecommitdiff
path: root/src/trace/pathtrace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/trace/pathtrace.rs')
-rw-r--r--src/trace/pathtrace.rs9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/trace/pathtrace.rs b/src/trace/pathtrace.rs
index 32a8e15..a3a688a 100644
--- a/src/trace/pathtrace.rs
+++ b/src/trace/pathtrace.rs
@@ -20,11 +20,10 @@ impl PathTracer<'_> {
pub fn trace_recur(&self, sampler: &mut dyn Sampler, ray: &Ray) -> Spectrum {
- if let Some(i) = self.scn.intersect(ray) {
- // Get a random direction in the hemisphere a i.p
- // This is Lambertian reflection
- let target = i.p + i.n + sampler.get_unit_vector();
- return self.trace_recur(sampler, &Ray::new_to(i.p, target)) * 0.5;
+ if let Some((mat, i)) = self.scn.intersect(ray) {
+ if let Some((scalar, nray)) = mat.scatter(ray, &i, sampler) {
+ return self.trace_recur(sampler, &nray) * scalar;
+ }
}
// Simulates a sky