Nori  23
Sampler Class Referenceabstract

Abstract sample generator. More...

#include <sampler.h>

Inheritance diagram for Sampler:
Collaboration diagram for Sampler:

Public Member Functions

virtual ~Sampler ()
 Release all memory.
 
virtual std::unique_ptr< Samplerclone () const =0
 Create an exact clone of the current instance.
 
virtual void prepare (const ImageBlock &block)=0
 Prepare to render a new image block. More...
 
virtual void generate ()=0
 Prepare to generate new samples. More...
 
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.
 
virtual EClassType getClassType () const override
 Return the type of object (i.e. Mesh/Sampler/etc.) provided by this instance.
 
- Public Member Functions inherited from NoriObject
virtual ~NoriObject ()
 Virtual destructor.
 
virtual void addChild (NoriObject *child)
 Add a child object to the current instance. More...
 
virtual void setParent (NoriObject *parent)
 Set the parent object. More...
 
virtual void activate ()
 Perform some action associated with the object. More...
 
virtual std::string toString () const =0
 Return a brief string summary of the instance (for debugging purposes)
 
void setIdName (const std::string &name)
 Allow to assign a name to the object.
 
const std::string & getIdName () const
 

Protected Attributes

size_t m_sampleCount
 
- Protected Attributes inherited from NoriObject
std::string m_idname
 

Additional Inherited Members

- Public Types inherited from NoriObject
enum  EClassType {
  EScene = 0 , EMesh , ETexture , EBSDF ,
  EPhaseFunction , EEmitter , EMedium , ECamera ,
  EIntegrator , ESampler , ETest , EReconstructionFilter ,
  EClassTypeCount
}
 
- Static Public Member Functions inherited from NoriObject
static std::string classTypeName (EClassType type)
 Turn a class type into a human-readable string.
 

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 63 of file sampler.h.

Member Function Documentation

◆ generate()

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.

Implemented in Independent.

◆ prepare()

virtual void Sampler::prepare ( const ImageBlock block)
pure virtual

Prepare to render a new image block.

This function is called when the sampler begins rendering a new image block. This can be used to deterministically initialize the sampler so that repeated program runs always create the same image.

Implemented in Independent.


The documentation for this class was generated from the following file: