Page MenuHome

Cycles: switch from pretabulated 2D PMJ02 to pretabulated 4D Sobol.
ClosedPublic

Authored by Nathan Vegdahl (cessen) on Nov 10 2022, 1:30 AM.

Details

Summary

The first two dimensions of scrambled, shuffled Sobol and shuffled PMJ02 are equivalent, so this makes no real difference for the first two dimensions. But Sobol allows us to naturally extend to more dimensions.

This in turn allows the following two things (also implemented):

  • Use proper 3D samples for combined lens + motion blur sampling. This notably reduces the noise on objects that are simultaneously out-of-focus and motion blurred.
  • Use proper 3D samples for combined light selection + light sampling. Cycles was already doing something clever here with 2D samples, but using 3D samples is more straightforward and avoids overloading one of the dimensions.

In the future this will also allow for proper sampling of e.g. volumetric light sources and other things that may need three or four dimensions.

Diff Detail

Repository
rB Blender
Branch
pretabulated_sobol (branched from master)
Build Status
Buildable 24596
Build 24596: arc lint + arc unit

Event Timeline

Nathan Vegdahl (cessen) requested review of this revision.Nov 10 2022, 1:30 AM
Nathan Vegdahl (cessen) created this revision.

I've currently left the file and function names as "jitter", "pmj", etc. But this feels a little odd now that it's not PMJ anymore. I'm happy to change them in this patch as well, but want to double check what good names would be. Maybe "tabulated_sobol" or "tab_sobol"?

Brecht Van Lommel (brecht) requested changes to this revision.Nov 10 2022, 2:16 PM

Maybe name it tabulated_sobol_burley and sample/tabulated_sobol_burley.h?

Since these are now the same pattern, we should also make the sampling pattern purely a debugging option that's not visible by default in the UI. Similar to for example the CYCLES_RENDER_PT_sampling_path_guiding_debug panel.

Any particular reason the order is (time, lens_x, lens_y) and (light_u, light_v, light_pick)? I don't know if and how the order affects the quality of the (lens_x, lens_y) and (light_u, light_v) 2D patterns, but I'd expect these two cases to be ordered the same.

This revision now requires changes to proceed.Nov 10 2022, 2:16 PM

Maybe name it tabulated_sobol_burley and sample/tabulated_sobol_burley.h?

This isn't really Sobol-Burley, though. The sampling pattern is equivalent (they're both Owen-scrambled/shuffled Sobol), but it's not generated using Burley's approach.

Maybe sobol_helmer, since it uses the technique from Helmer et al's paper to generate the samples...? (Although I suppose it is using Burley's approach just for the shuffling at render time.)

Since these are now the same pattern, we should also make the sampling pattern purely a debugging option that's not visible by default in the UI. Similar to for example the CYCLES_RENDER_PT_sampling_path_guiding_debug panel.

Yeah, that's a good idea. I'll add that to this patch.

Any particular reason the order is (time, lens_x, lens_y) and (light_u, light_v, light_pick)? I don't know if and how the order affects the quality of the (lens_x, lens_y) and (light_u, light_v) 2D patterns, but I'd expect these two cases to be ordered the same.

In my testing in Psychopath, using the first dimensions for time made a more noticeable quality difference than for DoF.

For light selection, I'm just going off the intuition that in many cases the light samples in a localized area will primarily be directed towards a single light source (particularly after light trees land), so having better stratification for light sampling probably makes a bigger difference than better stratification for light selection. But that's just a hunch, and I could totally end up being wrong. I can change it to (light_pick, light_u, light_v) if you prefer.

Move sample pattern into debug-hidden panel.

This isn't really Sobol-Burley, though. The sampling pattern is equivalent (they're both Owen-scrambled/shuffled Sobol), but it's not generated using Burley's approach.

Maybe sobol_helmer, since it uses the technique from Helmer et al's paper to generate the samples...? (Although I suppose it is using Burley's approach just for the shuffling at render time.)

Maybe just tabulated_sobol as your original suggestion then.

In my testing in Psychopath, using the first dimensions for time made a more noticeable quality difference than for DoF.

For light selection, I'm just going off the intuition that in many cases the light samples in a localized area will primarily be directed towards a single light source (particularly after light trees land), so having better stratification for light sampling probably makes a bigger difference than better stratification for light selection. But that's just a hunch, and I could totally end up being wrong. I can change it to (light_pick, light_u, light_v) if you prefer.

Ok, the reasoning makes sense to me then, it's fine to keep it as is. We can compare the two options with many lights sampling at some point.

  • Rename pmj02 files/functions/constants to tabulated Sobol.
  • Format code with clang-format.
Nathan Vegdahl (cessen) edited the summary of this revision. (Show Details)

Unless you have any other notes, then I think once we test this with many lights sampling it's good to go.

Brecht Van Lommel (brecht) requested changes to this revision.Nov 21 2022, 7:23 PM

The implementation in this patch looks fine to me, didn't spot issues from reading the code. But it will need to be rebased on D16561.

This revision now requires changes to proceed.Nov 21 2022, 7:23 PM

Great! Will D16561 also be merged into master, or should I just rebase directly on D16561 and then this patch will effectively get both into master?

I merged D16561 into master just now (everything from blender-v3.4-release gets merged).

Nathan Vegdahl (cessen) edited the summary of this revision. (Show Details)Nov 21 2022, 7:52 PM

Awesome. I'll work on rebasing today.

  • Merge branch 'master' into pretabulated_sobol
  • Run clang-format.

@Brecht Van Lommel (brecht): I've updated the patch to latest master.

Also, here's a comparison for DoF + motion blur:

2d sampling (old)3d sampling (this patch)

In the upper left is an object that is motion blurred and another object that is out of focus. As expected, there isn't much difference there since they at most use 2 dimensions. But in the upper right is an object that is both motion blurred and out of focus, and this patch significantly reduces the noise there because it stratifies the time and lens dimensions.

Thomas Dinges (dingto) requested changes to this revision.Nov 22 2022, 11:30 AM

Nice work! One remark left, see inline comment.

intern/cycles/blender/addon/ui.py
371

Should reflect the enum property rename from SOBOL to SOBOL_BURLEY I guess. What does this mean for the feature as a whole? Will it work with TABULATED_SOBOL?

This revision now requires changes to proceed.Nov 22 2022, 11:30 AM

Ah! Yeah, that's an oversight. Thanks for the catch!

It still works with tabulated Sobol. Although in general, I feel like scrambling distance is a misfeature. The small performance improvement you get from the improved cache utilization is, I strongly suspect, not enough to make up for the poorer convergence rate and just generally poor render quality. So I wonder if we shouldn't just remove it entirely.

  • Missed a 'SOBOL' -> 'SOBOL_BURLEY'.
Nathan Vegdahl (cessen) marked an inline comment as done.Nov 23 2022, 11:59 PM
Alaska (Alaska) added a comment.EditedNov 24 2022, 4:50 AM

Edit: Remove since the comment is off topic

Thanks for the update, fine from my side now. :)

Rebase on master, in particular for the light tree.

This revision is now accepted and ready to land.Dec 14 2022, 3:56 PM