Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The "RNG" part of RixRNG stands for "Random Number Generator" even though the samples are not random at all.  The RixRNG class is basically just a wrapper around an array of per-shading-point sample contexts (SampleCtxArray) and an integer (numPts) specifying how many sample contexts there are in the array.  There is typically one SampleCtx for each point in a ray shading batch.  The RixRNG wrapper class makes it convenient to generate sample points (or new sample domains) for an entire ray shading batch with just a single function call.

...

The NewDomainDistrib() function is similar, but should be used where the new domain's expected number of samples differs from that of the parent and repeated visits may nor may not have the same sample count or may consume differing numbers of samples: distribution sampling.  This function generates an independent sample domain where the samples in that domain are stratified with respect to each other, but not with respect to previous or future samples in the same pixel.  The new patternid depends on the scramble bits, the parent's patternid, and the current sampleid – including the sampleid ensures that there is a new, independent sample distribution for every iteration.  The sampleid of the new SampleCtx is set to the value of the 'newsampleid' parameter.  In normal use, the new domain should be created with newsampleid = 0, and then the sampleid should be incremented every time a new sample from that domain has been used.

SampleCtx NewDomainSplit(Scramble scramble, unsigned newnumsamples);

The NewDomainSplit() function is also similar to NewDomain(), but should be used where every visit will consume the same number of samples, and it is expected that all sibling visits will also always result in the drawing of a new domain – thus exploring the full space.   A fancy term for this is "trajectory splitting".  (If newnumsamples is 1 this call is the same as NewDomain(scramble).)

...

There are also similar functions in the RixRNG class that can fill in new domains (patternids) for an entire array of sample contexts (RixRNG sampleCtxArray): NewDomains(), NewDomainsDistrib(), and NewDomainsSplit().

The scramble bit patterns can be any 32-bit pattern, but it is important that the scramble bit pattern to generate different new domains are different.  For example, if an Integrator is generating new domains for bxdf and light source sampling, those should use different scramble bit patterns.  Otherwise there will be correlation between bxdf and light source sampling, leading to visible artifacts and poor convergence – or even no convergence at all!  Examples of bit patterns used in the PxrPathTracer Integrator are 0x2d96c92b, 0x3917fe2e, and 0xdeb189cf; there isn't anything particular about these bit patterns, the main point is that they are "random" and different.  The same scramble bit patterns can be used at different ray depths because the parent ray's patternids will differ, so when we generate a new patternid based on a different parent patternid and the same scramble, the new patternid will be different.

Integrators call RixRNG constructors to set up sample domains for bxdfs lobe selection and sampling, light selection and sampling, stochastic transmission, volume scattering, and several other things.  

...

Example:  Here is an example where a sampleCtxArray is allocated, a RixRNG is constructed (containing that sampleCtxArray), and the RixRNG's sampleCtxArray is initialized by by looping over shading points:

Code Block
  SampleCtx* samplectxarray = new SampleCtx[numPts];
  RixRNG rng(parentRNGparentRng, samplectxarray, numPts);
  RixRNG::Scramble scramble = static_cast<RixRNG::Scramble>(0x8732f9a1)
  for (int pt = 0; pt < numPts; pt++)
  {
    int index = shadingContext->integratorCtxIndex[pt];
    samplectxarray[pt] = parentRNG→NewDomainsplitparentRng→NewDomainsplit(index, scramble, 4);
  }

Here the scramble bit-pattern is 0x8732f9a1 and the splitting factor is 4.

...