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 {