Skip to content

Commit

Permalink
Fixed issue with prbvolpath gradient propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
Microno95 committed Apr 25, 2023
1 parent e3a5a8c commit 2ca6695
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/emitters/volumelight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class VolumeLight final : public Emitter<Float, Spectrum> {
m_flags = +EmitterFlags::Medium;

dr::set_attr(this, "flags", m_flags);
dr::set_attr(this, "radiance", m_radiance);
}

void traverse(TraversalCallback *callback) override {
Expand Down
7 changes: 6 additions & 1 deletion src/python/python/ad/integrators/prbvolpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,14 @@ def sample(self,
null_scatter = (sampler.next_1d(active_medium) < (emission_prob + null_prob))
act_null_scatter = null_scatter & active_medium
act_medium_scatter = ~null_scatter & active_medium
L[act_null_scatter] += throughput * radiance * dr.detach(weight * emission_weight)
contrib = throughput * radiance * dr.detach(emission_weight * weight)
L[act_null_scatter] += dr.detach(contrib if is_primal else -contrib)
weight[act_null_scatter] *= mei.sigma_n * dr.detach(null_weight)
else:
scatter_weight = mi.Float(1.0)
act_medium_scatter = active_medium
contrib = dr.zeros(mi.UnpolarizedSpectrum)


depth[act_medium_scatter] += 1
last_scatter_event[act_medium_scatter] = dr.detach(mei)
Expand All @@ -291,6 +294,8 @@ def sample(self,
if not is_primal and dr.grad_enabled(weight):
Lo = dr.detach(dr.select(active_medium | escaped_medium, L / dr.maximum(1e-8, weight), 0.0))
dr.backward(δL * weight * Lo)
if not is_primal and dr.grad_enabled(contrib):
dr.backward(δL * contrib)

phase_ctx = mi.PhaseFunctionContext(sampler)
phase = mei.medium.phase_function()
Expand Down

0 comments on commit 2ca6695

Please sign in to comment.