From ae3931e79613449e47349730b8359f1ae8e4594d Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 9 May 2020 02:05:12 +0200 Subject: [PATCH] library: render: don't return infinite weight hemisphere sampling previously could return infinite, producing NaNs when later multiplying that weight by 0. --- pathtracer/src/render/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pathtracer/src/render/utils.rs b/pathtracer/src/render/utils.rs index 18c5755..1fdbaf6 100644 --- a/pathtracer/src/render/utils.rs +++ b/pathtracer/src/render/utils.rs @@ -101,7 +101,7 @@ pub fn sample_hemisphere(normal: Unit) -> (Unit, f32) { // The probability to have picked the ray is inversely proportional to cosine of the angle with // the normal - (scattered, 1. / scattered.dot(&normal)) + (scattered, (1. / scattered.dot(&normal)).min(f32::MAX)) } pub fn buffer_to_image(buffer: &[LinearColor], passes: u32, width: u32, height: u32) -> RgbImage {