|
|
|
@ -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);
|
|
|
|
|
|
|
|
|
|