Sampler class

Abstract sample generator.

A sample generator is responsible for generating the random number stream that will be passed to an #Integrator implementation as it computes the radiance incident along a specified ray.

Derived classes

class IndependentSampler
Independent sampling - returns independent uniformly distributed random numbers in $[0, 1)$ .

Public functions

auto clone() const -> std::unique_ptr<Sampler> pure virtual
Create an exact copy of this Sampler instance.
void set_base_seed(uint32_t s) virtual
Set the base seed for the sampler (passed in as a command-line argument).
void start_pixel(int x, int y) virtual
Prepare to generate samples for pixel (x,y).
void advance() virtual
Advance to the next sample.
auto next1f() -> float pure virtual
Retrieve the next float value (dimension) from the current sample.
auto next2f() -> Vec2f pure virtual
Retrieve the next two float values (dimensions) from the current sample.
auto sample_count() const -> uint32_t virtual
Return the number of configured pixel samples.

Function documentation

void Sampler::set_base_seed(uint32_t s) virtual

Set the base seed for the sampler (passed in as a command-line argument).

Setting the seed of the underlying RNG deterministically is important to produce identical results between runs.

This function should only need to be called once before rendering starts.

void Sampler::start_pixel(int x, int y) virtual

Prepare to generate samples for pixel (x,y).

This function is called every time the integrator starts rendering a new pixel.

The base class simply resets the current dimension to zero, but derived classes may want to e.g. compute a new seed based on the pixel coordinates. If you do so, make sure to still make the per-pixel seed depend on m_base_seed.