Skip to content

[MLT] bootstrap samples differ #48

Closed
@wahn

Description

@wahn

Since commit 87b0b5e we can generate bootstrap paths multi-threaded. While debugging something else I figured that the generated bootstrap samples differ slightly between the C++ and Rust version. To dig deeper into the problem I modified both versions to print out very specialized information regarding the test scene (assets/scenes/caustic.pbrt) and the resulting bootstrap samples.

In Rust (src/core/sampling.rs):

impl Distribution1D {
    pub fn new(f: Vec<Float>) -> Self {
        let n: i32 = f.len() as i32;
        // compute integral of step function at $x_i$
        let mut cdf: Vec<Float> = Vec::with_capacity(n as usize + 1);
        cdf.push(0.0 as Float);
        for i in 1..(n + 1) {
...
            if n == 600000 && f[(i - 1) as usize] > 0.0 as Float {
                println!("f[{:?}] = {1:2.8}", i - 1, f[(i - 1) as usize]);
            }
        }
...
    }
...
}

In C++ (src/core/sampling.h):

struct Distribution1D {
    // Distribution1D Public Methods
    Distribution1D(const Float *f, int n) : func(f, f + n), cdf(n + 1) {
        // Compute integral of step function at $x_i$
        cdf[0] = 0;
        for (int i = 1; i < n + 1; ++i) {
          if (n == 600000 && f[i - 1] > 0.0) {
            printf("f[%d] = %2.8f\n", i - 1, f[i - 1]);
          }
...
    }
...
};

I will attach the resulting difference between both versions to the issue and report on any progress ...

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions