Page MenuHome

Cycles PMJ adaptive sampling working poorly with many bounces
Needs ReviewPublic

Authored by William Leeson (leesonw) on Jul 9 2021, 4:11 PM.

Details

Summary

Adding shuffling to the PMJ sampler so it does not use the same sample set for the same dimension causing it to miss features instead the dimension is shuffled. Still need to add the shuffling for PMJ but this provides some tools to experiment with the issue. Just if you are interested.

Diff Detail

Repository
rB Blender

Event Timeline

William Leeson (leesonw) requested review of this revision.Jul 9 2021, 4:11 PM
William Leeson (leesonw) created this revision.
William Leeson (leesonw) edited the summary of this revision. (Show Details)

Now I have added the fixes for the PMJ sampler by shuffling the samples along x and y this creates a greater number of variations. The mask was causing issues with the sample pattern. I also added the shuffle now to the 1D sampler.

I think something went wrong with the latest update, since I see no changes.

I cleaned up the code a bit and removed some debug output. Additionally, I provided a few more UI options (in the advanced settings) to allow some sample shuffling methods on the quasi-monte carlo methods. For the fix you don't need to touch these at all as it uses sensible defaults. Also the pixel hash now default to the Tong hash as the regular hash clashes with that used in other parts of cycles.

Incorrect int which should have been a uint.

It's a bit unclear to me which part of this is required to fix the bug, and which is new sampling algorithms that may or may not give better results.

For the bugfix, are both the different pixel hash (to avoid a correlation) and addition of nested_uniform_scramble needed? nested_uniform_scramble looks expensive so I'm not sure this is something we should be doing for every sample. I'm a bit confused because as far as I can tell the PMJ paper gives an alternative to Sobol + Owen scrambling, but this uses both the tables and Owen scrambling? It's not clear to me why this is necessary.

We need to benchmark it in any case, see here for how to set that up. Then you can also look at the resulting renders to see if they look better/worse.
https://wiki.blender.org/wiki/Tools/Tests/Performance

For the other pixel hash and sampling patterns, we'll need to see if they provide any practical benefit before adding them. We generally do not add options unless there is a demonstratable benefit on test scenes. Some code can be added for testing, but it would not be compiled into the kernel unless there is a benefit for end-users.

For the pixel hashing, I don't really see a benefit to having multiple pseudo-random number generators, since as long as there is no correlation one should not be better than the other? There are approaches like blue noise dithering that add correlation between neighboring pixels intentionally, but as far as I can tell that's not what we are doing here.

I totally agree. The intention with this patch was to provide a number of solutions the UI options were so as to be able to test them in various combinations easily. The are a number of issues being fixed. The pixel hash was to fix correlation when sampling the edges as the use of the current hash had a issue causing the samples to correlate along the edges. This showed up particularly well with de-noising . The shuffling was to remove correlation from the sample scheme as the xor method was not functioning correctly resulting in a poor sample set and correlation which contributed to the depth issues. I added the qmc method as it provided both a cheaper sampling method and also was faster on the CPU which also solved the problems. It is basically a Sobol sequence which has similar performance to the pmj method with the advantage of being infinite. I need to put a bit more work into seeing if the xor scrambling can be fixed though.

Added code to support bit reverse instructions when they are available for faster sample generation.

Adding 1D scrambling that I forgot to include before.

Extract out some common code from the random and pmj parts and also rearrange the if to fall through for pmj which should make it potentially faster as there will be less jumps.

Removed all the QMC stuff and only focused on fixing the sampling and the hashing so as to just fix the reported bug. It also extends the max number of samples before it falls back to random sampling.

Edit: Ignore this message. The issue described in it has disappeared.

Added Owen shuffling back in to stop correlation between dimension that can occur. This also allowed the use of way fewer sample patterns to achieve the same results.

Reduced the PMJ sample sets to 1 and used Cranley Patterson Rotation with Owen shuffle.

Removed some files I accidentally added.

Removed some commented out code.