Fix MIS bugs

This commit is contained in:
hal8174 2025-01-08 22:31:57 +01:00
parent 27ea5c5d93
commit 908efa79c2
5 changed files with 33 additions and 15 deletions

View file

@ -36,12 +36,7 @@ where
if let Some(light) = i.light() {
if count == 0 {
sum += alpha * light.emit(w_in, rng);
}
}
let w_out = if let Some(material) = i.material() {
let sample_result = material.sample(w_in, rng);
if let Some(light) = i.light() {
} else {
let dist = i.t() / r.dir().length();
let path_pdf = last_bsdf_pdf;
@ -50,6 +45,10 @@ where
let b = path_pdf / (path_pdf + nee_pdf);
sum += b * alpha * light.emit(w_in, rng);
}
}
let w_out = if let Some(material) = i.material() {
let sample_result = material.sample(w_in, rng);
if let Some(l) = scene.sample_light(w_in, &i, rng) {
let light_frame = l.tangent_frame();
@ -82,7 +81,11 @@ where
}
}
last_bsdf_pdf = material.pdf(w_in, sample_result.w_out());
if sample_result.is_delta() {
last_bsdf_pdf = 100000.0;
} else {
last_bsdf_pdf = material.pdf(w_in, sample_result.w_out());
}
alpha *= sample_result.color();
sample_result.w_out()
} else {