Skip to content

Add prbvolpath_sm: new unbiased differentiable volume integrator with sample matching - #1939

Open
AuroraRyan0301 wants to merge 2 commits into
mitsuba-renderer:masterfrom
AuroraRyan0301:sample-matching-pr
Open

Add prbvolpath_sm: new unbiased differentiable volume integrator with sample matching#1939
AuroraRyan0301 wants to merge 2 commits into
mitsuba-renderer:masterfrom
AuroraRyan0301:sample-matching-pr

Conversation

@AuroraRyan0301

@AuroraRyan0301 AuroraRyan0301 commented Aug 19, 2026

Copy link
Copy Markdown

This PR adds prbvolpath_sm, a volumetric integrator that estimates extinction gradients with sample matching.

Ruihan Yu, Yu-Chen Wang, Jingwang Ling, Feng Xu, Shuang Zhao.
Sample Matching for Joint Extinction Gradient Estimation in Differentiable
Volume Rendering.
ACM Transactions on Graphics 45(4), 2026.
paper
· supplementary
· project page
· doi:10.1145/3811329

Denser media scatter more light toward the camera and also block more of the light passing through. These two terms of the extinction gradient have opposite signs. prbvolpath estimates them at unrelated points; prbvolpath_sm estimates both at the same points on each path segment, which cancels most of the variance. The primal image is the same as prbvolpath; all changes are in the adjoint pass.

The adjoint pass runs as two kernels. The path replay loop writes one record per segment, and a second kernel reads the records and traces new rays for the gradient samples. segment_slots sets how many records a path may keep. Any number of slots is unbiased. By default it is max_depth + 1, so every segment gets a record. With one slot, a path keeps a single segment chosen by weighted reservoir sampling; this setting is also registered as prbvolpath_sm_linear, and the default as prbvolpath_sm_quad.

Spectral variants and extinction that varies across channels are supported. Polarized variants and forward mode are not, same as prbvolpath.

Testing

Bunny cloud, one A40, 8000 iterations. PSNR is measured on the held-out view at 256 spp:

prbvolpath prbvolpath_sm_linear prbvolpath_sm_quad (default)
gradient variance, same spp 1 0.29 0.25
PSNR 26.66 dB 35.71 dB 38.35 dB
time 41.6 h 22.6 h 26.3 h

extinction gradient mean and variance

Gradients agree with finite differences within 1% in RGB and spectral variants. The test suite passes on cuda_ad_rgb, cuda_ad_spectral, llvm_ad_rgb and llvm_ad_spectral.

Checklist

  • My code follows the style guidelines of this project
  • My changes generate no new warnings
  • My code also compiles for cuda_* and llvm_* variants. If you can't test this, please leave below
  • I have commented my code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I cleaned the commit history and removed any "Merge" commits
  • I give permission that the Mitsuba 3 project may redistribute my contributions under the terms of its license

@AuroraRyan0301 AuroraRyan0301 changed the title Add prbvolpath_sm: sample matching for volumetric extinction gradients Add prbvolpath_sm: new differentiable volume integrator with sample matching Aug 19, 2026
@AuroraRyan0301 AuroraRyan0301 changed the title Add prbvolpath_sm: new differentiable volume integrator with sample matching Add prbvolpath_sm: new unbiased differentiable volume integrator with sample matching Aug 19, 2026
@AuroraRyan0301
AuroraRyan0301 force-pushed the sample-matching-pr branch 4 times, most recently from 4b1d38f to e667d40 Compare August 20, 2026 23:06
@wjakob

wjakob commented Aug 31, 2026

Copy link
Copy Markdown
Member

Hello Ruihan,

thank you for this PR. I am excited to ship this feature as part of Mitsuba. However, there are some aspects of the current realization in a PR that will need further work:

  • the PR message and some parts of the commits look like they came straight out of Claude code. Generally direct output from LLMs is below the quality bar of this project.
  • It's a big change at +2.5K LOC
  • Part of why it is so big is that you introduce unrelated functionality for supergrids. I think that should really be factored out in its own PR so that we can discuss what a good interface could be. For example right now you baked DDA traversal into the bottom-level Medium class, but the bottom-level classes are designed to be very abstract to accommodate many possible implementations. For example, some users of Mitsuba (Rayference/Eradiate) work with curved grids for planetary data. If we bake a rectilinear version as the core interface, it will be completely incompatible with their workflow.

Best,
Wenzel

@AuroraRyan0301

AuroraRyan0301 commented Sep 10, 2026

Copy link
Copy Markdown
Author

Hi Wenzel,

Thanks for the feedback, and sorry for the late reply. I apologize for leaving so much AI-generated content in the PR. I just wanted to get the discussion about the PR and its design started quickly. While porting the implementation to Mitsuba 3.9, I mainly focused on supporting a broad range of variants, including spectral rendering, and achieving good performance.

I have now split out the features and simplified the commits and PR description. I have also removed the supergrid functionality for now, since making it compatible with Eradiate seems to require substantial changes to the interface. I hope the revised code is closer to the project's quality standards.

Thanks again for your time and support.

Best,
Ruihan

prbvolpath_sm merges the transmittance and scattering terms of the DRTE
to reduce the variance of the extinction grid's gradient in the
optimization. Primal rendering stays the same as prbvolpath. The adjoint
pass runs as two kernels: the replay loop writes one record per segment
and a second kernel traces the gradient samples of the recorded segments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants