Nori
|
Abstract sample generator. More...
#include <sampler.h>
Public Member Functions | |
virtual | ~Sampler () |
Release all memory. | |
virtual Sampler * | clone ()=0 |
Clone the current instance. | |
virtual void | generate ()=0 |
Prepare to generate new samples. | |
virtual void | advance ()=0 |
Advance to the next sample. | |
virtual float | next1D ()=0 |
Retrieve the next component value from the current sample. | |
virtual Point2f | next2D ()=0 |
Retrieve the next two component values from the current sample. | |
virtual size_t | getSampleCount () const |
Return the number of configured pixel samples. | |
EClassType | getClassType () const |
Return the type of object (i.e. Mesh/Sampler/etc.) provided by this instance. | |
Protected Attributes | |
size_t | m_sampleCount |
Abstract sample generator.
A sample generator is responsible for generating the random number stream that will be passed an Integrator implementation as it computes the radiance incident along a specified ray.
The most simple conceivable sample generator is just a wrapper around the Mersenne-Twister random number generator and is implemented in independent.cpp
(it is named this way because it generates statistically independent random numbers).
Fancier samplers might use stratification or low-discrepancy sequences (e.g. Halton, Hammersley, or Sobol point sets) for improved convergence. Another use of this class is in producing intentionally correlated random numbers, e.g. as part of a Metropolis-Hastings integration scheme.
The general interface between a sampler and a rendering algorithm is as follows: Before beginning to render a pixel, the rendering algorithm calls generate(). The first pixel sample can now be computed, after which advance() needs to be invoked. This repeats until all pixel samples have been exhausted. While computing a pixel sample, the rendering algorithm requests (pseudo-) random numbers using the next1D() and next2D() functions.
Conceptually, the right way of thinking of this goes as follows: For each sample in a pixel, a sample generator produces a (hypothetical) point in an infinite dimensional random number hypercube. A rendering algorithm can then request subsequent 1D or 2D components of this point using the next1D() and next2D() functions. Fancy implementations of this class make certain guarantees about the stratification of the first n components with respect to the other points that are sampled within a pixel.
virtual Sampler::~Sampler | ( | ) | [inline, virtual] |
virtual void Sampler::advance | ( | ) | [pure virtual] |
Advance to the next sample.
virtual Sampler* Sampler::clone | ( | ) | [pure virtual] |
Clone the current instance.
This is used to create a separate sampler for each thread when rendering with multiple cores. The clone is expected to be different to some extent, e.g. a pseudorandom generator should be based on a different random seed compared to the original. Other parameters (e.g. those that influence the stratification quality) should be copied exactly.
virtual void Sampler::generate | ( | ) | [pure virtual] |
Prepare to generate new samples.
This function is called initially and every time the integrator starts rendering a new pixel.
EClassType Sampler::getClassType | ( | ) | const [inline, virtual] |
Return the type of object (i.e. Mesh/Sampler/etc.) provided by this instance.
Implements NoriObject.
virtual size_t Sampler::getSampleCount | ( | ) | const [inline, virtual] |
virtual float Sampler::next1D | ( | ) | [pure virtual] |
Retrieve the next component value from the current sample.
virtual Point2f Sampler::next2D | ( | ) | [pure virtual] |
Retrieve the next two component values from the current sample.
size_t Sampler::m_sampleCount [protected] |