Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mathematical confusion of Global sampler array samples #334

Open
longpractice opened this issue Mar 3, 2024 · 0 comments
Open

Mathematical confusion of Global sampler array samples #334

longpractice opened this issue Mar 3, 2024 · 0 comments

Comments

@longpractice
Copy link

longpractice commented Mar 3, 2024

I read through the implementation of the GlobalSampler with the low discrepency digital sequences.

One thing confuses me most is that for 1D and 2D array samples, the sample and dimension seems to have a miss match:

Let's say we use

  1. Halton sequence.
  2. We request 3 samples per pixel.
  3. For each pixel, we request one 1d array with 5 elements.

Now from the implementation of GlobalSample::StartPixel

void GlobalSampler::StartPixel(const Point2i &p) {
    ProfilePhase _(Prof::StartPixel);
    Sampler::StartPixel(p);
    dimension = 0;
    intervalSampleIndex = GetIndexForSample(0);
    // Compute _arrayEndDim_ for dimensions used for array samples
    arrayEndDim =
        arrayStartDim + sampleArray1D.size() + 2 * sampleArray2D.size();

    // Compute 1D array samples for _GlobalSampler_
    for (size_t i = 0; i < samples1DArraySizes.size(); ++i) {
        int nSamples = samples1DArraySizes[i] * samplesPerPixel;
        for (int j = 0; j < nSamples; ++j) {
            int64_t index = GetIndexForSample(j);
            sampleArray1D[i][j] = SampleDimension(index, arrayStartDim + i);
        }
    }

    // Compute 2D array samples for _GlobalSampler_
    int dim = arrayStartDim + samples1DArraySizes.size();
    for (size_t i = 0; i < samples2DArraySizes.size(); ++i) {
        int nSamples = samples2DArraySizes[i] * samplesPerPixel;
        for (int j = 0; j < nSamples; ++j) {
            int64_t idx = GetIndexForSample(j);
            sampleArray2D[i][j].x = SampleDimension(idx, dim);
            sampleArray2D[i][j].y = SampleDimension(idx, dim + 1);
        }
        dim += 2;
    }
    CHECK_EQ(arrayEndDim, dim);
}

For our first sample, the 5 elements of the requested 1D array comes from the Halton sequence samples:

GetIndexForSample(0), 
GetIndexForSample(1),
GetIndexForSample(2),
GetIndexForSample(3),
GetIndexForSample(4)

, while other non-array values come from the GetIndexForSample(0) Halton sequence sample.

For our second sample, the 5 elements of the requested single 1D array comes from the Halton sequence samples:

GetIndexForSample(5), 
GetIndexForSample(6),
GetIndexForSample(7),
GetIndexForSample(8),
GetIndexForSample(9)

, while the other non-array values come from the GetIndexForSample(1) Halton sequence sample.

This seems breaks the simple explanation/definition of the low discrepency sequence. The 1D/2D arrays from a sample in our sampler comes from different samples of low discrepency digital sequences. I wonder if there is any mathematical explanation of this?

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

No branches or pull requests

1 participant