1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use crate::tracer::Integrator;
#[derive(argh::FromArgs)]
/// Optional CLI configuration of renderer. Renderer setter methods have priority.
pub struct TracerCli {
/// number of samples per pixel (defaults to 1)
#[argh(option, short = 's', default = "1")]
pub samples: i32,
/// number of threads used (defaults to all)
#[argh(option, short = 't')]
pub threads: Option<usize>,
/// use direct light integrator instead of path tracing
#[argh(switch, short = 'd', long = "direct")]
pub direct_light: bool,
/// use bidirectional path tracing instead of path tracing
#[argh(switch, short = 'b', long = "bdpt")]
pub bd_path_trace: bool,
}
impl TracerCli {
/// Sets the configured number of threads. Called by renderer on creation.
pub fn set_threads(&self) {
if let Some(t) = self.threads {
rayon::ThreadPoolBuilder::new()
.num_threads(t)
.build_global()
.unwrap();
}
}
/// Get the configured integrator.
pub fn get_integrator(&self) -> Integrator {
if self.direct_light {
Integrator::DirectLight
} else if self.bd_path_trace {
Integrator::BDPathTrace
} else {
Integrator::PathTrace
}
}
}