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§
Sourcefn start_pixel(&mut self, p: Point2<u32>)
fn start_pixel(&mut self, p: Point2<u32>)
Start sampling a new pixel
Sourcefn sample_per_pixel(&self) -> usize
fn sample_per_pixel(&self) -> usize
maximum sample count per pixel
Sourcefn next_sample(&mut self) -> bool
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
Sourcefn set_sample_index(&mut self, idx: usize) -> bool
fn set_sample_index(&mut self, idx: usize) -> bool
try to set current sample to a particular index
Provided Methods§
Sourcefn get_camera_sample(&mut self, idx: Point2<u32>) -> SampleInfo
fn get_camera_sample(&mut self, idx: Point2<u32>) -> SampleInfo
convinient method to sample a camera
Sourcefn get_light_sample(&mut self) -> SampleInfo
fn get_light_sample(&mut self) -> SampleInfo
convinient method to sample a light
Sourcefn request(&mut self, buf: &mut [Float])
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
Sourcefn request_2d(&mut self, buf: &mut [Point2f])
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
Sourcefn round_count(&self, n: usize) -> usize
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.