Skip to content

Implementation of "Single-pass stratified importance resampling"

License

Notifications You must be signed in to change notification settings

EgeCiklabakkal/spsir

Repository files navigation

Single-pass stratified importance resampling

Implementation of our paper "Single-pass stratified importance resampling" by Ege Ciklabakkal, Adrien Gruson, Iliyan Georgiev, Derek Nowrouzezahrai, and Toshiya Hachisuka.

The implementation builds on the pbrt, version 3 renderer. The project can be built in the same way as pbrt.

For further details, we refer to the project webpage.

Building Spsir

Built the same way as pbrt.

$ git clone --recursive git@github.com:EgeCiklabakkal/spsir.git
$ cd spsir
$ mkdir build
$ cd build
$ cmake ..
$ make -j8

Scenes

We include the scenes used to generate the renderings in the paper. For further details on the scenes we refer to README.

Note that in all scenes, ray per pixel is set to 1 and these primary rays go through the center of the pixels. We do so to focus on the variance (reduction) from resampled importance sampling (RIS). Our method can be extended to multiple sample per pixel by using a low-discrepancy sequence to sample the primary rays and querying the blue-noise mask with independent offsets. Previous work has found that the R2-sequence is a good choice for such offset.

To reproduce the exact figures, some modifications to the code would be necessary (For example, fig. 6 reorders the candidates after they are generated, which is not our exact algorithm), however our main method is implemented to cover each sampling problem we present in the paper.

Code Organization

The following is the list of changed / new files for our method:

1. src/core/api.cpp

Parse and make medium HomogeneousBlockingMedium

2. src/core/dithermask.*

Class for DitherMask of any dimension. Should be used with dither masks created by Dithering Mask Generator

3. src/core/hilbertcurve.*

Class for HilbertCurve of any dimension. The main interface is the sample function which returns the primary sample space candidate (all components in [0,1)) along the Hilbert Curve, given a random number u. There is also the simpler 2D version HilbertCurve2D for better performance.

4. src/core/integrator.*

Includes many functions implementing our method.

[Reservoir,InverseCDF,BidirectionalCDF]LightOnly(...) functions implement RIS with 2D candidates of light samples, using reservoir sampling, inverse CDF sampling, and our bidirectional CDF sampling respectively. Reservoir sampling doesn't utilize our Hilbert Curve reordering and instead uses low-discrepancy sequences (this is also the case for other sampling problems). It serves as a reasonable baseline. The other methods do utilize the Hilbert Curve reordering.

[Reservoir,InverseCDF,BidirectionalCDF]BSDFEnvMIS(...) functions implement RIS with candidates generated by sampling either the BSDF or the environment light. The candidates are then weighted by multiple importance sampling (MIS). This weighting is the same as Sec. 4.6.1 Multiple Importance Sampling applied to Proposals from Talbot's thesis These functions assume that there is only the environment map as the light. Our goal here is to show that we can combine our method with MIS.

There are also functions related to volume sampling.

5. src/core/light.*

Virtual method so sample light and return pdf in area measure (instead of solid angle measure).

6. src/core/medium.h

enum class of volume sampling strategies RISReservoir, RISInverseCDF, RISBidirectionalCDF along virtual methods for our volume sampling experiments.

7. src/core/reservoir.h

Implements the Reservoir class, also includes the classes for candidates.

8. src/core/sampler.*

Implements the R2-sequence to offset the DitherMask. This offset is controlled by a seed provided by the user. Different offsets can be used to generate multiple outputs to be averaged.

9. src/core/shape.*

Virtual method to help return area measure when sampling lights.

10. src/integrators/directlighting.* and src/integrators/volpath.*

Integrator modified to read variables needed for our methods and call them appropriately.

11. src/lights/diffuse.* and src/lights/point.*

Sample lights and return pdf in area measure.

12. src/media/homogeneousblocking.*

Implements the HomogeneousBlockingMedium that represents the volume such that the ray inside it always samples a medium interaction. In other words, the objects inside the medium are never shaded, but they affect the maximum distance if the ray. Therefore we can see the objects in a way, however they are not shaded. This medium allows us to focus only on sampling a distance along the ray. In our experiments, the volume always exists throughout the whole scene (it is not confined in an object).

For the first experiment, we consider a single point light inside the homogeneous medium and single scattering as the sampling problem (i.e. sampling distance along primary rays). The relevant method is SampleLightDriven(...) (samples according to the given light) which calls SampleRIS[Reservoir,iCDF,Bidirectional]LightDriven(...) similarly to our 2D direct lighting experiments.

For the second experiment, our goal is to sample distance along the ray and a direction to some (area) light so that our candidates are 3D. The relevant method is SampleDistDir(...) which calls SampleRIS[Reservoir,Bidirectional]DistDir(...).

How to cite

@article{Ciklabakkal:2022:StratifiedResampling,
  author = {Ege Ciklabakkal and Adrien Gruson and Iliyan Georgiev and Derek Nowrouzezahrai and Toshiya Hachisuka},
  title = {Single-pass stratified importance resampling},
  journal = {Computer Graphics Forum (Proceedings of EGSR)},
  year = {2022},
  number = {4},
  volume = {41}
}

About

Implementation of "Single-pass stratified importance resampling"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages