Skip to content

Commit 9b22128

Browse files
committed
Fix epsilon issue for volpath integrators
1 parent ffcde97 commit 9b22128

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

src/integrators/volpath.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ class VolumetricPathIntegrator : public MonteCarloIntegrator<Float, Spectrum> {
339339
return { emitter_val, ds };
340340
}
341341

342-
Ray3f ray = ref_interaction.spawn_ray(ds.d);
342+
Ray3f ray = ref_interaction.spawn_ray_to(ds.p);
343+
Float max_dist = ray.maxt;
343344

344345
// Potentially escaping the medium if this is the current medium's boundary
345346
if constexpr (std::is_convertible_v<Interaction, SurfaceInteraction3f>)
@@ -356,7 +357,7 @@ class VolumetricPathIntegrator : public MonteCarloIntegrator<Float, Spectrum> {
356357
sampler->loop_put(loop);
357358
loop.init();
358359
while (loop(dr::detach(active))) {
359-
Float remaining_dist = ds.dist * (1.f - math::ShadowEpsilon<Float>) - total_dist;
360+
Float remaining_dist = max_dist - total_dist;
360361
ray.maxt = remaining_dist;
361362
active &= remaining_dist > 0.f;
362363
if (dr::none_or<false>(active))

src/integrators/volpathmis.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ class VolpathMisIntegratorImpl final : public MonteCarloIntegrator<Float, Spectr
391391
return { p_over_f_nee, p_over_f_uni, emitter_val, ds};
392392
}
393393

394-
Ray3f ray = ref_interaction.spawn_ray(ds.d);
394+
Ray3f ray = ref_interaction.spawn_ray_to(ds.p);
395+
Float max_dist = ray.maxt;
395396

396397
// Potentially escaping the medium if this is the current medium's boundary
397398
if constexpr (std::is_convertible_v<Interaction, SurfaceInteraction3f>)
@@ -408,8 +409,7 @@ class VolpathMisIntegratorImpl final : public MonteCarloIntegrator<Float, Spectr
408409
sampler->loop_put(loop);
409410
loop.init();
410411
while (loop(dr::detach(active))) {
411-
412-
Float remaining_dist = ds.dist * (1.f - math::ShadowEpsilon<Float>) - total_dist;
412+
Float remaining_dist = max_dist - total_dist;
413413
ray.maxt = remaining_dist;
414414
active &= remaining_dist > 0.f;
415415
if (dr::none_or<false>(active))

src/python/python/ad/integrators/prbvolpath.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ def sample_emitter(self, mei, si, active_medium, active_surface, scene, sampler,
331331
medium = dr.select(active, medium, dr.zeros(mi.MediumPtr))
332332
medium[(active_surface & si.is_medium_transition())] = si.target_medium(ds.d)
333333

334-
ray = ref_interaction.spawn_ray(ds.d)
334+
ray = ref_interaction.spawn_ray_to(ds.p)
335+
max_dist = mi.Float(ray.maxt)
335336
total_dist = mi.Float(0.0)
336337
si = dr.zeros(mi.SurfaceInteraction3f)
337338
needs_intersection = mi.Bool(True)
@@ -340,7 +341,7 @@ def sample_emitter(self, mei, si, active_medium, active_surface, scene, sampler,
340341
state=lambda: (sampler, active, medium, ray, total_dist,
341342
needs_intersection, si, transmittance))
342343
while loop(active):
343-
remaining_dist = ds.dist * (1.0 - mi.math.ShadowEpsilon) - total_dist
344+
remaining_dist = max_dist - total_dist
344345
ray.maxt = dr.detach(remaining_dist)
345346
active &= remaining_dist > 0.0
346347

0 commit comments

Comments
 (0)