fix a possible cause of NaNs
This commit is contained in:
parent
cb4dcc53f1
commit
77c1a87e4f
@ -180,7 +180,13 @@ public final class SimpleRenderer implements Renderer {
|
||||
} else {
|
||||
var mixed = new MixtureProbabilityDensityFunction(new TargetingProbabilityDensityFunction(hit.position(), scene.getLights()), pdf, 0.5);
|
||||
var direction = mixed.generate(random);
|
||||
var factor = pdf.value(direction) / mixed.value(direction);
|
||||
|
||||
var idealPdf = pdf.value(direction);
|
||||
var actualPdf = mixed.value(direction);
|
||||
if (actualPdf == 0) break; // when actualPdf is 0, the ray should have never been generated by mixed.generate
|
||||
|
||||
var factor = idealPdf / actualPdf;
|
||||
|
||||
attenuation = Color.multiply(attenuation, Color.multiply(a, factor));
|
||||
ray = new Ray(hit.position(), direction);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user