wahn / rs_pbrt

Rust crate to implement a counterpart to the PBRT book's (3rd edition) C++ code. See also https://www.rs-pbrt.org/about ...
https://www.rs-pbrt.org
Other
809 stars 59 forks source link

Implement CreateStratifiedSampler #122

Closed wahn closed 4 years ago

wahn commented 4 years ago

On the C++ side:

> rg -tcpp CreateStratifiedSampler
samplers/stratified.cpp
79:StratifiedSampler *CreateStratifiedSampler(const ParamSet &params) {

core/api.cpp
835:        sampler = CreateStratifiedSampler(paramSet);

samplers/stratified.h
66:StratifiedSampler *CreateStratifiedSampler(const ParamSet &params);

TODO: Rust counterpart ...

wahn commented 4 years ago

After commit 1f805e793d5a393559f88bed209b8338a63b1a0b we get a 100% match to the C++ counterpart:

> imf_diff pbrt_rust.exr pbrt.exr
pbrt_rust.exr pbrt.exr: no differences.
== "pbrt_rust.exr" and "pbrt.exr" are identical

Still there are some bits and pieces missing:

impl StratifiedSampler {
...
    pub fn start_pixel(&mut self, p: &Point2i) {
...
        // generate arrays of stratified samples for the pixel
        for i in 0..self.samples_1d_array_sizes.len() {
            //     for (int64_t j = 0; j < samplesPerPixel; ++j) {
            //         int count = samples1DArraySizes[i];
            //         stratified_sample_1d(&sampleArray1D[i][j * count], count, rng,
            //                            self.jitter_samples);
            //         Shuffle(&sampleArray1D[i][j * count], count, 1, rng);
        }
        for i in 0..self.samples_2d_array_sizes.len() {
            //     for (int64_t j = 0; j < samplesPerPixel; ++j) {
            //         int count = samples2DArraySizes[i];
            //         LatinHypercube(&sampleArray2D[i][j * count].x, count, 2, rng);
        }
...
    }
...
}
wahn commented 4 years ago

After commit e057694f138658274d530ee1afc43b8a20b3bce6 the latin_hypercube(...) method works as well (being used e.g. for ambientocclusion):

> imf_diff pbrt.exr pbrt_rust.exr
pbrt.exr pbrt_rust.exr: no differences.
== "pbrt.exr" and "pbrt_rust.exr" are identical

Closing the issue for now.