This is a follow-up to D15679, completing what was still left over in
in order to fully replace D15485. Namely, fixing the PMJ sampler.
There were two main things that were broken in the PMJ sampler,
resulting in more noise:
- The sample pattern generating code itself wasn't quite right, and
resulted in patterns that weren't properly progressive in the way
that PMJ02 is supposed to be. Specifically, only power-of-two
*prefixes* were properly stratified, not suffixes.
- In order to try to get away with just a single sample pattern, the
code used a combination of sample index shuffling andThis resulted in unnecessarily increased noise when using non-power-of-two sample counts.
Cranley-Patterson rotation. Index shuffling is normally fine- In order to try to get away with just a single sample pattern, but
the code used a combination of sample index shuffling and Cranley-Patterson rotation. Index shuffling is normally fine, but due to the sample patterns themselves not being quite right (as
described above) this actually resulted in additional increased noise.
Cranley-Patterson, on the other hand, always increases noise with
randomized (t,s) nets like PMJ02, and should be aviooided with these
kinds of sequences.
This patch fixes those issues with the following changes:
- It replaces the sample pattern generation code with a much
simpler algorithm recently published in a new paper. This is both
This is both easier to verify and *far* faster than the previous code, being O(N) in the number of samples generated.
- It keeps the sample index shuffling, which works correctly now due to the fixed sample patterns. O(N) in the number of samples generatedBut it now uses a newer high-quality hash instead of the original Laine-Karras hash.
- It keeps the sample index shufflingThe scrambling distance feature cannot (to my knowledge) be implemented with any decorrelation strategy other than Cranley-Patterson, so Cranley-Patterson is still used when that feature is enabled. But it is now disabled otherwise, which works correctly nowsince it increases noise.
due to the fixed sample patterns. But it now uses a newer
high-quality hash instead of the original Laine-Karras hash.
- The scrambling distance feature cannot (to my knowledge) be
implemented with any decorrelation strategy other than
Cranley-Patterson, so Cranley-Patterson is still used when
that feature is enabled. But it is now disabled otherwise,
since it increases noise.
- In place of Cranley-Patterson, multiple independent patterns are
generated and randomly chosen for different pixels and dimensions
as described in the original PMJ paper. In this patch, the
pattern selection is done via hash-based shuffling to ensure there
are no repeats within a single pixel until all patterns have been
used.
The combination of these fixes brings the quality of Cycles' PMJ
PMJ sampler in line with the previously submitted Sobol-Burley sampler
in D15679. They are essentially indistinguishable in terms of
in D15679. They are essentially indistinguishable in terms of quality/noise, which is expected since they are both randomized
(0,2) sequences.