[][src]Trait tray_rust::sampler::Sampler

pub trait Sampler {
    fn get_samples(&mut self, samples: &mut Vec<(f32, f32)>, rng: &mut StdRng);
fn get_samples_2d(&mut self, samples: &mut [(f32, f32)], rng: &mut StdRng);
fn get_samples_1d(&mut self, samples: &mut [f32], rng: &mut StdRng);
fn max_spp(&self) -> usize;
fn has_samples(&self) -> bool;
fn dimensions(&self) -> (u32, u32);
fn select_block(&mut self, start: (u32, u32));
fn get_region(&self) -> &Region; fn report_results(&mut self, _samples: &[ImageSample]) -> bool { ... } }

Provides the interface for all samplers to implement. Defines functions for getting samples from the sampler and checking the sampler has finished sampling the region

Required methods

fn get_samples(&mut self, samples: &mut Vec<(f32, f32)>, rng: &mut StdRng)

Fill the vector with 2D pixel coordinate samples for a single pixel in the region being sampled. If the sampler doesn't have any more samples for the region the vector will be empty Samplers that use randomness to compute samples will use the thread rng

fn get_samples_2d(&mut self, samples: &mut [(f32, f32)], rng: &mut StdRng)

Fill the slice with 2D samples from the sampler

fn get_samples_1d(&mut self, samples: &mut [f32], rng: &mut StdRng)

Fill the slice with 1D samples from the sampler

fn max_spp(&self) -> usize

Get the max number of samples this sampler will take per pixel

fn has_samples(&self) -> bool

Check if the sampler has more samples for the region being sampled

fn dimensions(&self) -> (u32, u32)

Get the dimensions of the region being sampled in pixels

fn select_block(&mut self, start: (u32, u32))

Move to a new block of the image to sample with this sampler by specifying the starting (x, y) block index for the new block. The block starting position will be calculated as dimensions * start

fn get_region(&self) -> &Region

Get the region being samples

Loading content...

Provided methods

fn report_results(&mut self, _samples: &[ImageSample]) -> bool

Let the sampler inspect the results of sampling the pixel so it can determine if more samples should be taken. Returns true if these samples are ok to use, false if more need to be taken. The default implementation just returns true.

Loading content...

Implementors

impl Sampler for Adaptive[src]

impl Sampler for LowDiscrepancy[src]

impl Sampler for Uniform[src]

Loading content...