Fix nans for MIS renderer
This commit is contained in:
parent
2269bd102d
commit
95092b1571
1 changed files with 10 additions and 3 deletions
|
|
@ -24,7 +24,7 @@ where
|
|||
let mut r = camera.forward(x, y, rng);
|
||||
|
||||
let mut count = 0;
|
||||
let mut last_bsdf_pdf = 0.0;
|
||||
let mut last_bsdf_pdf = 1.0;
|
||||
|
||||
while let Some(i) = scene.intersect(r, 0.001, Float::INFINITY) {
|
||||
let frame = i.tangent_frame();
|
||||
|
|
@ -40,9 +40,16 @@ where
|
|||
let dist = i.t() / r.dir().length();
|
||||
|
||||
let path_pdf = last_bsdf_pdf;
|
||||
let nee_pdf = i.light_pdf() * dist * dist / w_in.y();
|
||||
let nee_pdf = if i.light_pdf() != 0.0 {
|
||||
i.light_pdf() * dist * dist / w_in.y()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let b = path_pdf / (path_pdf + nee_pdf);
|
||||
let b = path_pdf / (path_pdf + nee_pdf + 0.000001);
|
||||
if b.is_nan() {
|
||||
dbg!(b, path_pdf, nee_pdf);
|
||||
}
|
||||
sum += b * alpha * light.emit(w_in, rng);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue