Skip to content

Commit

Permalink
PRBVolpath: Re-evaluate phase function sampling weight in a different…
Browse files Browse the repository at this point in the history
…iable way
  • Loading branch information
bathal1 authored and njroussel committed Oct 6, 2023
1 parent 721a851 commit 5f9eebd
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/python/python/ad/integrators/prbvolpath.py
Expand Up @@ -278,10 +278,20 @@ def sample(self,
sampler.next_2d(act_medium_scatter),
act_medium_scatter)
act_medium_scatter &= phase_pdf > 0.0

# Re evaluate the phase function value in an attached manner
phase_eval, _ = phase.eval_pdf(phase_ctx, mei, wo, act_medium_scatter)
if not is_primal and dr.grad_enabled(phase_eval):
Lo = phase_eval * dr.detach(dr.select(active, L / dr.maximum(1e-8, phase_eval), 0.0))
if mode == dr.ADMode.Backward:
dr.backward_from(δL * Lo)
else:
δL += dr.forward_to(Lo)

throughput[act_medium_scatter] *= phase_weight
ray[act_medium_scatter] = mei.spawn_ray(wo)
needs_intersection |= act_medium_scatter
last_scatter_direction_pdf[act_medium_scatter] = phase_pdf
throughput[act_medium_scatter] *= phase_weight

# ------------------------ BSDF sampling -----------------------

Expand Down

0 comments on commit 5f9eebd

Please sign in to comment.