Nori

Sampler Class Reference

Abstract sample generator. More...

#include <sampler.h>

Inheritance diagram for Sampler:
NoriObject

List of all members.

Public Member Functions

virtual ~Sampler ()
 Release all memory.
virtual Samplerclone ()=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

Detailed Description

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.

Definition at line 60 of file sampler.h.


Constructor & Destructor Documentation

virtual Sampler::~Sampler ( ) [inline, virtual]

Release all memory.

Definition at line 63 of file sampler.h.


Member Function Documentation

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.

Definition at line 100 of file sampler.h.

virtual size_t Sampler::getSampleCount ( ) const [inline, virtual]

Return the number of configured pixel samples.

Definition at line 94 of file sampler.h.

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.


Member Data Documentation

size_t Sampler::m_sampleCount [protected]

Definition at line 102 of file sampler.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines