Trait Sampler

Source
pub trait Sampler:
    Clone
    + Sync
    + Send {
    // Required methods
    fn start_pixel(&mut self, p: Point2<u32>);
    fn next(&mut self) -> Float;
    fn sample_per_pixel(&self) -> usize;
    fn next_sample(&mut self) -> bool;
    fn set_sample_index(&mut self, idx: usize) -> bool;

    // Provided methods
    fn next_2d(&mut self) -> Point2f { ... }
    fn get_camera_sample(&mut self, idx: Point2<u32>) -> SampleInfo { ... }
    fn get_light_sample(&mut self) -> SampleInfo { ... }
    fn request(&mut self, buf: &mut [Float]) { ... }
    fn request_2d(&mut self, buf: &mut [Point2f]) { ... }
    fn round_count(&self, n: usize) -> usize { ... }
}
Expand description

The sampling interface. Samplers should return sampled values in $[0, 1)$.

Additional information are provided through the interface (like pixel location, dimension, samples per pixel etc.) such that implementations might provide better-quality.

Required Methods§

Source

fn start_pixel(&mut self, p: Point2<u32>)

Start sampling a new pixel

Source

fn next(&mut self) -> Float

get next 1-dimensional sample

Source

fn sample_per_pixel(&self) -> usize

maximum sample count per pixel

Source

fn next_sample(&mut self) -> bool

Try to advance to the next sample true if the sampling process can continue false when overflowing sample_per_pixel, eg

Source

fn set_sample_index(&mut self, idx: usize) -> bool

try to set current sample to a particular index

Provided Methods§

Source

fn next_2d(&mut self) -> Point2f

get next 2-dimensional sample

Source

fn get_camera_sample(&mut self, idx: Point2<u32>) -> SampleInfo

convinient method to sample a camera

Source

fn get_light_sample(&mut self) -> SampleInfo

convinient method to sample a light

Source

fn request(&mut self, buf: &mut [Float])

request n samples in place Default implementation uses succeeding calls to self.next() to fill the buf, which might not be ideal

Source

fn request_2d(&mut self, buf: &mut [Point2f])

request n 2d samples in place Default implementation uses succeeding calls to self.next_2d() to fill the buf, which might not be ideal

Source

fn round_count(&self, n: usize) -> usize

Optimal round count, as a hint

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§