pbrt_r3/core/sampler/
sampler.rs1use crate::core::base::*;
2use crate::core::camera::*;
3
4use std::sync::Arc;
5use std::sync::RwLock;
6pub trait Sampler {
23 fn start_pixel(&mut self, _p: &Point2i) {}
24 fn get_1d(&mut self) -> Float;
25 fn get_2d(&mut self) -> Point2f;
26 fn get_camera_sample(&mut self, p: &Point2i) -> CameraSample {
27 let p_film = Point2f::new(p.x as Float, p.y as Float) + self.get_2d();
28 let p_lens = self.get_2d();
29 let time = self.get_1d();
30 CameraSample {
32 p_film,
33 p_lens,
34 time,
35 }
36 }
37 fn request_1d_array(&mut self, _n: u32);
38 fn request_2d_array(&mut self, _n: u32);
39 fn get_1d_array(&mut self, n: u32) -> Option<Vec<Float>>;
40 fn get_2d_array(&mut self, n: u32) -> Option<Vec<Vector2f>>;
41 fn round_count(&self, n: u32) -> u32 {
42 return n;
43 }
44 fn start_next_sample(&mut self) -> bool {
45 return false;
46 }
47 fn clone_with_seed(&self, seed: u32) -> Arc<RwLock<dyn Sampler>>;
48 fn set_sample_number(&mut self, _sample_num: u32) -> bool {
49 return false;
50 }
51 fn get_samples_per_pixel(&self) -> u32;
52}