IndependentSampler class

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

This class is essentially just a wrapper around a pseudorandom number generator. For more details on what sample generators do in general, refer to the Sampler class.

Base classes

class Sampler
Abstract sample generator.

Public functions

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

Function documentation

std::unique_ptr<Sampler> IndependentSampler::clone() const override

Create an exact clone of the current instance.

This is useful if you want to duplicate a sampler to use in multiple threads

void IndependentSampler::set_base_seed(uint32_t s) override

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 IndependentSampler::start_pixel(int x, int y) override

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.