Skip to content

Commit 81398c8

Browse files
stefanatworkCopilot
andcommitted
Fix pathtracer double-counting ambient light
Skip ambient lights in next-event estimation since they are already added when rays escape the scene. Fixes #491. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 02f30e2 commit 81398c8

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎tutorials/pathtracer/pathtracer_device.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,6 +1564,8 @@ Vec3fa renderPixelFunction(const TutorialData& data, float x, float y, RandomSam
15641564
for (unsigned int i=0; i<data.ispc_scene->numLights; i++)
15651565
{
15661566
const Light* l = data.ispc_scene->lights[i];
1567+
/* ambient light is already accounted for when rays escape */
1568+
if (l->type == LIGHT_AMBIENT) continue;
15671569
//Light_SampleRes ls = l->sample(l,dg,RandomSampler_get2D(sampler));
15681570
Light_SampleRes ls = Lights_sample(l,dg,RandomSampler_get2D(sampler));
15691571
if (ls.pdf <= 0.0f) continue;

‎tutorials/pathtracer/pathtracer_device.ispc‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,8 @@ Vec3f renderPixelFunction(const uniform TutorialData& data, float x, float y, Ra
15621562
for (uniform unsigned int i=0; i<data.ispc_scene->numLights; i++)
15631563
{
15641564
const uniform Light* uniform l = data.ispc_scene->lights[i];
1565+
/* ambient light is already accounted for when rays escape */
1566+
if (l->type == LIGHT_AMBIENT) continue;
15651567
//Light_SampleRes ls = l->sample(l,dg,RandomSampler_get2D(sampler));
15661568
Light_SampleRes ls = Lights_sample(l,dg,RandomSampler_get2D(sampler));
15671569
if (ls.pdf <= 0.0f) continue;

0 commit comments

Comments
 (0)