Skip to content

Commit 75e3e51

Browse files
committed
Fix MIS weights
1 parent 422845f commit 75e3e51

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

App/CL/integrator_pt.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ __kernel void ShadeSurface(
411411
// Sample light
412412
float3 le = Light_Sample(light_idx, &scene, &diffgeo, TEXTURE_ARGS, Sampler_Sample2D(&sampler, SAMPLER_ARGS), &lightwo, &lightpdf);
413413
lightbxdfpdf = Bxdf_GetPdf(&diffgeo, wi, normalize(lightwo), TEXTURE_ARGS);
414-
lightweight = Light_IsSingular(&scene.lights[light_idx]) ? 1.f : BalanceHeuristic(1, lightpdf, 1, lightbxdfpdf);
414+
lightweight = Light_IsSingular(&scene.lights[light_idx]) ? 1.f : BalanceHeuristic(1, lightpdf / selection_pdf, 1, lightbxdfpdf);
415415

416416
// Apply MIS to account for both
417417
if (NON_BLACK(le) && lightpdf > 0.0f && !Bxdf_IsSingular(&diffgeo))

App/CL/light.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ float3 AreaLight_Sample(// Emissive object
219219

220220
if (ndotv > 0.f)
221221
{
222-
float dist2 = (length(*wo) * length(*wo));
222+
float dist2 = dot(*wo, *wo);
223223
float denom = fabs(ndotv) * area;
224224
*pdf = denom > 0.f ? dist2 / denom : 0.f;
225225
return dist2 > 0.f ? ke * ndotv / dist2 : 0.f;

0 commit comments

Comments
 (0)