library: render: don't return infinite weight
hemisphere sampling previously could return infinite, producing NaNs when later multiplying that weight by 0.
This commit is contained in:
parent
dad5113724
commit
ae3931e796
|
@ -101,7 +101,7 @@ pub fn sample_hemisphere(normal: Unit<Vector>) -> (Unit<Vector>, f32) {
|
||||||
|
|
||||||
// The probability to have picked the ray is inversely proportional to cosine of the angle with
|
// The probability to have picked the ray is inversely proportional to cosine of the angle with
|
||||||
// the normal
|
// 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 {
|
pub fn buffer_to_image(buffer: &[LinearColor], passes: u32, width: u32, height: u32) -> RgbImage {
|
||||||
|
|
Loading…
Reference in a new issue