From 543f2719e4e3ba5b01555faebb946e8125570b8e Mon Sep 17 00:00:00 2001 From: Nathan Vegdahl Date: Mon, 4 Jul 2016 11:54:46 -0700 Subject: [PATCH] Fixed bugs in global illumination. It was a stupid thing in the Lambert closure. It was returning the wrong direction vector. --- src/renderer.rs | 2 +- src/shading/surface_closure.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 82e8976..d1177b4 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -276,7 +276,7 @@ impl LightPath { // in shadow or not. // TODO: use proper ray offsets for avoiding self-shadowing // rather than this hacky stupid stuff. - *ray = Ray::new(pos + shadow_vec.normalized() * 0.0001, + *ray = Ray::new(pos + shadow_vec.normalized() * 0.001, shadow_vec, self.time, true); diff --git a/src/shading/surface_closure.rs b/src/shading/surface_closure.rs index 55dd9a5..1ef4d80 100644 --- a/src/shading/surface_closure.rs +++ b/src/shading/surface_closure.rs @@ -185,7 +185,7 @@ impl SurfaceClosure for LambertClosure { uv: (f32, f32), wavelength: f32) -> (Vector, SpectralSample, f32) { - let nn = if dot(nor.into_vector().normalized(), inc.normalized()) <= 0.0 { + let nn = if dot(nor.into_vector(), inc) <= 0.0 { nor.normalized() } else { -nor.normalized() @@ -199,7 +199,7 @@ impl SurfaceClosure for LambertClosure { let out = zup_to_vec(dir, nn); let filter = self.evaluate(inc, out, nor, wavelength); - (dir, filter, pdf) + (out, filter, pdf) } fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, wavelength: f32) -> SpectralSample {