Skip to main content

polyscope_core/
tone_mapping.rs

1//! Tone mapping configuration.
2
3use serde::{Deserialize, Serialize};
4
5/// Tone mapping configuration.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ToneMappingConfig {
8    /// Exposure multiplier (default 1.0).
9    pub exposure: f32,
10    /// White level for highlight compression (default 1.0).
11    pub white_level: f32,
12    /// Gamma correction exponent (default 2.2).
13    pub gamma: f32,
14}
15
16impl Default for ToneMappingConfig {
17    fn default() -> Self {
18        Self {
19            exposure: 1.0,
20            white_level: 1.0,
21            gamma: 2.2,
22        }
23    }
24}
25
26impl ToneMappingConfig {
27    /// Creates a new tone mapping configuration with default values.
28    #[must_use]
29    pub fn new() -> Self {
30        Self::default()
31    }
32
33    /// Sets the exposure value.
34    #[must_use]
35    pub fn with_exposure(mut self, exposure: f32) -> Self {
36        self.exposure = exposure;
37        self
38    }
39
40    /// Sets the white level.
41    #[must_use]
42    pub fn with_white_level(mut self, white_level: f32) -> Self {
43        self.white_level = white_level;
44        self
45    }
46
47    /// Sets the gamma value.
48    #[must_use]
49    pub fn with_gamma(mut self, gamma: f32) -> Self {
50        self.gamma = gamma;
51        self
52    }
53}