Skip to content

Commit 9992164

Browse files
committed
Fix to ignore geometric term for non area lights
1 parent 59acefa commit 9992164

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

sample/scene/cornell_box.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ std::unique_ptr<Camera> CornellBox(Scene& scene)
6666
// auto mat = CreateThinDielectricMaterial(scene, 1.5f);
6767

6868
auto tf = Transform{ 0.66f, hy, -0.33f, Quat(DegToRad(-18.0f), y_axis), Vec3(hx * 2.0f, hy * 2.0f, hz * 2.0f) };
69-
// CreateBox(scene, tf, right_box);
69+
CreateBox(scene, tf, right_box);
7070
}
7171

7272
// Right sphere
7373
{
74-
CreateSphere(scene, Transform(Vec3(0.65f, 0.15f, -0.3f), Quat(DegToRad(0), x_axis)), 0.15f, glass);
74+
// CreateSphere(scene, Transform(Vec3(0.65f, 0.15f, -0.3f), Quat(DegToRad(0), x_axis)), 0.15f, rough_glass);
7575
}
7676

7777
// Lights

src/integrator/bidirectional_path_integrator.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ int32 BiDirectionalPathIntegrator::SampleLightPath(Vertex* path, Sampler& sample
100100
v.pdf_rev = 0;
101101
}
102102

103-
Spectrum beta =
104-
light_sample.Le * AbsDot(light_sample.normal, light_sample.ray.d) / (sl.pmf * light_sample.pdf_p * light_sample.pdf_w);
103+
Spectrum beta = light_sample.Le / (sl.pmf * light_sample.pdf_p * light_sample.pdf_w);
104+
if (light_sample.normal != Vec3::zero)
105+
{
106+
beta *= AbsDot(light_sample.normal, light_sample.ray.d);
107+
}
105108

106109
// Note light paths sample one fewer vertex than the target path length
107110
return 1 + RandomWalk(

src/integrator/light_path_integrator.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,11 @@ Spectrum LightPathIntegrator::L(
6969
int32 bounce = 0;
7070
Ray ray = light_sample.ray;
7171

72-
Spectrum beta =
73-
light_sample.Le * AbsDot(light_sample.normal, ray.d) / (sampled_light.pmf * light_sample.pdf_p * light_sample.pdf_w);
72+
Spectrum beta = light_sample.Le / (sampled_light.pmf * light_sample.pdf_p * light_sample.pdf_w);
73+
if (light_sample.normal != Vec3::zero)
74+
{
75+
beta *= AbsDot(light_sample.normal, ray.d);
76+
}
7477

7578
// Trace light path
7679
while (true)

src/integrator/light_vol_path_integrator.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,12 @@ Spectrum LightVolPathIntegrator::L(
7070
int32 bounce = 0;
7171
Ray ray = light_sample.ray;
7272

73-
Spectrum beta =
74-
light_sample.Le * AbsDot(light_sample.normal, ray.d) / (sampled_light.pmf * light_sample.pdf_p * light_sample.pdf_w);
73+
Spectrum beta = light_sample.Le / (sampled_light.pmf * light_sample.pdf_p * light_sample.pdf_w);
74+
if (light_sample.normal != Vec3::zero)
75+
{
76+
beta *= AbsDot(light_sample.normal, ray.d);
77+
}
78+
7579
Spectrum r_u(1);
7680

7781
// Trace light path

0 commit comments

Comments
 (0)