viewport-lib-types 0.2.0

Pure-data types for viewport-lib: submission payloads, handles, and frame config, free of any GPU dependency.
Documentation
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
//! Post-process configuration such as tone mapping applied at display time.

/// Tone mapping operator used by the HDR pipeline.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ToneMapping {
    /// Reinhard tone mapping (simple, good for scenes without extreme HDR).
    Reinhard,
    /// ACES filmic tone mapping (cinematic look, strong colour shift).
    Aces,
    /// Khronos Neutral tone mapping (perceptually uniform, minimal colour shift).
    ///
    /// Values in [0, 1] pass through with little change. Only meaningful work
    /// is done on HDR values above 1.0. This is the default.
    #[default]
    KhronosNeutral,
}

/// Neutral exposure numerator. Cancels the `1.2` maxLuminance divisor so
/// `ExposureMode::Manual { ev: 0.0 }` maps to a linear multiplier of exactly
/// `1.0`, keeping exposure neutral while light intensities are still unitless
/// (`~1`, not yet lux/candela). It goes away once lights carry photometric
/// units, when the full `exposure = 1 / (1.2 * 2^EV)` form becomes correct.
#[doc(hidden)]
pub const INTERIM_EXPOSURE_BOOST: f32 = 1.2;

/// Reflected-light meter calibration constant `K` used to convert an average
/// scene luminance to EV100 (`EV100 = log2(L * 100 / K)`). `12.5` is the
/// standard reflected-light value.
#[doc(hidden)]
pub const METER_CALIBRATION_K: f32 = 12.5;

/// How the pre-tone-map exposure multiplier is derived each frame.
///
/// Every mode resolves to a single linear multiplier applied to scene radiance
/// before tone mapping (see `tone_map.wgsl`). The multiplier is routed through a
/// small GPU buffer so auto-exposure can write it from a compute pass in the
/// same submission as the tone map, keeping a one-shot (dirty-only) render
/// correctly exposed on its own frame.
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ExposureMode {
    /// Manual EV100. `ev = 0.0` is the neutral default (a `1.0` multiplier
    /// during the interim; see `INTERIM_EXPOSURE_BOOST`). Higher EV darkens.
    Manual {
        /// Exposure value at ISO 100. Higher is darker.
        ev: f32,
    },
    /// Physical-camera triangle. `EV100 = log2(N^2 / t) + log2(100 / ISO)`.
    PhysicalCamera {
        /// f-number `N` (aperture). Larger = smaller aperture = darker.
        aperture: f32,
        /// Shutter time `t` in seconds. Longer = brighter.
        shutter: f32,
        /// Sensor sensitivity (ISO). Higher = brighter.
        iso: f32,
    },
    /// Auto-exposure: meter the HDR target's log-luminance histogram each frame
    /// and adapt an internal EV toward it (see [`AutoExposure`]).
    Automatic(AutoExposure),
}

impl ExposureMode {
    /// The physically-neutral default: a fixed `EV 0` manual exposure.
    pub const NEUTRAL: ExposureMode = ExposureMode::Manual { ev: 0.0 };
}

/// Auto-exposure metering and adaptation parameters (used by
/// [`ExposureMode::Automatic`]).
///
/// Metering reduces the HDR target to a percentile-clipped average
/// log-luminance, converts it to a target EV100, and eases an internal EV
/// toward it. `dt` is the smoothing control: `dt <= 0` snaps to the target this
/// frame (the default, correct for consumers that render only when dirty);
/// `dt > 0` applies exponential smoothing (the "eye adjusting" look).
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AutoExposure {
    /// Lower clamp on the adapted EV100. Default: `-8.0`.
    pub min_ev: f32,
    /// Upper clamp on the adapted EV100. Default: `18.0`.
    pub max_ev: f32,
    /// Adaptation rate (per second) when the scene gets brighter (EV rising).
    /// Larger adapts faster. Default: `3.0`.
    pub speed_up: f32,
    /// Adaptation rate (per second) when the scene gets darker (EV falling).
    /// Default: `1.0`.
    pub speed_down: f32,
    /// Frame time in seconds for temporal smoothing. `<= 0` snaps to the target
    /// this frame (no adaptation animation). `ViewportApp` auto-fills this from
    /// `ctx.dt`; hand-written hosts pass it (or `0.0`). Default: `0.0`.
    pub dt: f32,
    /// Lower edge of the metering window: the cumulative pixel fraction below
    /// which luminances are discarded before averaging, in `[0, 1)`. Together
    /// with `high_percent` this meters an upper-mid luminance *band* rather than
    /// the whole frame. Metering that band (not the bulk) is what keeps exposure
    /// stable as the camera orbits: the brightest lit surfaces have a nearly
    /// framing-invariant luminance, whereas the frame *average* swings as a large
    /// surface (a floor, a wall) grows or shrinks in view. Default: `0.65`.
    pub low_percent: f32,
    /// Upper edge of the metering window: the cumulative fraction above which the
    /// brightest pixels are discarded, in `(low_percent, 1]`. Rejects fireflies /
    /// specular highlights so a stray hot pixel does not drive exposure.
    /// Default: `0.95`.
    pub high_percent: f32,
    /// Center-weighting of the meter, in `[0, 1]`. `0` meters the whole frame
    /// uniformly (exposure then swings as bright content enters/leaves the frame
    /// on zoom/pan); `1` weights the centre strongly so a centred subject drives
    /// exposure and framing barely moves it. Default: `0.85`.
    pub center_weight: f32,
    /// Adaptation strength in `[0, 1]`: how fully the exposure follows the
    /// metered scene. `1` (the default) is full auto-exposure, driving the metered
    /// value to middle grey so the scene is correctly exposed regardless of its
    /// magnitude. `0` holds a fixed exposure. The correction is scaled from a
    /// neutral (EV 0) anchor, so values below `1` leave scenes far from EV 0
    /// permanently under-corrected: a real-daylight scene at `0.5` stays several
    /// stops overexposed. Lower it only for near-neutral lighting where you want a
    /// touch of brightness constancy and smaller framing-driven swings (orbit,
    /// zoom onto a bright/dark object). Default: `1.0`.
    pub adaptation: f32,
}

impl Default for AutoExposure {
    fn default() -> Self {
        Self {
            min_ev: -8.0,
            max_ev: 18.0,
            speed_up: 3.0,
            speed_down: 1.0,
            dt: 0.0,
            low_percent: 0.65,
            high_percent: 0.95,
            center_weight: 0.85,
            adaptation: 1.0,
        }
    }
}

/// Physical-camera exposure configuration for the HDR pipeline.
///
/// Passed via `EffectsFrame::exposure`. `compensation` is a stops-of-bias
/// applied on top of every mode (positive brightens the image).
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ExposureSettings {
    /// How the base exposure multiplier is derived. Default:
    /// [`ExposureMode::NEUTRAL`] (`Manual { ev: 0.0 }`) - a fixed neutral exposure
    /// that passes linear radiance straight through, so the faithful default
    /// lighting reads as authored ("colour is data"). Switch to
    /// [`ExposureMode::Automatic`] (e.g. via [`ExposureSettings::automatic`]) or
    /// [`ExposureMode::PhysicalCamera`] when authoring real photometric magnitudes
    /// that need mapping down.
    pub mode: ExposureMode,
    /// Exposure compensation in stops, applied on top of `mode`. Positive
    /// values brighten the image (lower the effective EV). Default: `0.0`.
    pub compensation: f32,
}

impl Default for ExposureSettings {
    fn default() -> Self {
        Self {
            mode: ExposureMode::NEUTRAL,
            compensation: 0.0,
        }
    }
}

impl ExposureSettings {
    /// An exposure from a mode, with no compensation.
    pub fn from_mode(mode: ExposureMode) -> Self {
        Self {
            mode,
            compensation: 0.0,
        }
    }

    /// Set the exposure compensation (stops); positive brightens.
    pub fn with_compensation(mut self, stops: f32) -> Self {
        self.compensation = stops;
        self
    }

    /// Convenience: a manual EV100 exposure with no compensation.
    pub fn manual(ev: f32) -> Self {
        Self {
            mode: ExposureMode::Manual { ev },
            compensation: 0.0,
        }
    }

    /// Convenience: a physical-camera exposure with no compensation.
    pub fn physical(aperture: f32, shutter: f32, iso: f32) -> Self {
        Self {
            mode: ExposureMode::PhysicalCamera {
                aperture,
                shutter,
                iso,
            },
            compensation: 0.0,
        }
    }

    /// Convenience: auto-exposure with default metering/adaptation parameters.
    pub fn automatic() -> Self {
        Self {
            mode: ExposureMode::Automatic(AutoExposure::default()),
            compensation: 0.0,
        }
    }

    /// The EV100 for the non-automatic modes. Returns `None` for `Automatic`,
    /// whose EV is metered on the GPU.
    #[doc(hidden)]
    pub fn base_ev100(&self) -> Option<f32> {
        match self.mode {
            ExposureMode::Manual { ev } => Some(ev),
            ExposureMode::PhysicalCamera {
                aperture,
                shutter,
                iso,
            } => Some(ev100_from_physical(aperture, shutter, iso)),
            ExposureMode::Automatic(_) => None,
        }
    }

    /// The linear exposure multiplier for the non-automatic modes, including
    /// `compensation`. Returns `None` for `Automatic`.
    #[doc(hidden)]
    pub fn manual_multiplier(&self) -> Option<f32> {
        self.base_ev100()
            .map(|ev| ev100_to_exposure(ev - self.compensation))
    }
}

/// EV100 from a physical-camera triangle:
/// `EV100 = log2(N^2 / t) + log2(100 / ISO)`.
pub(crate) fn ev100_from_physical(aperture: f32, shutter: f32, iso: f32) -> f32 {
    (aperture * aperture / shutter).log2() + (100.0 / iso).log2()
}

/// EV100 to a linear exposure multiplier via the maxLuminance form:
/// `maxLum = 1.2 * 2^EV100`, `exposure = boost / maxLum`. `boost` is the
/// temporary neutral numerator (see `INTERIM_EXPOSURE_BOOST`); it is `1.0` once
/// photometric units are pinned.
pub(crate) fn ev100_to_exposure(ev100: f32) -> f32 {
    let max_lum = 1.2 * 2.0_f32.powf(ev100);
    INTERIM_EXPOSURE_BOOST / max_lum
}

/// Which render pipeline turns scene geometry into display pixels.
///
/// `Hdr` is the main path; `Direct` is a constrained fallback for
/// host-owned render passes (`paint_to` / `paint_viewport`, which always use it)
/// and cheap inline rendering. `Direct` omits the HDR target and therefore
/// exposure, tone mapping, every post effect, OIT (so transparency is
/// order-dependent), the skybox, and item-type plugins. Transparent volume
/// meshes (`SceneFrame::transparent_volume_meshes`) require `Hdr`.
// NOT #[non_exhaustive]: a closed, consumer-selected binary (cf. `ToneMapping`).
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PipelineMode {
    /// Full HDR pipeline: HDR render target, exposure, tone mapping, all post
    /// effects, OIT, skybox, and item-type plugins. The default.
    #[default]
    Hdr,
    /// Constrained LDR passthrough: draw directly to the output surface with no
    /// post chain. Everything the HDR pipeline adds is skipped.
    Direct,
}

/// The display transform: how linear HDR radiance becomes display pixels.
///
/// Passed via `EffectsFrame::display`. Groups the three
/// controls of the HDR-to-display stage - the [`PipelineMode`] switch, the
/// [`ExposureSettings`] applied before tone mapping, and the [`ToneMapping`]
/// operator. Exposure and the operator are inert on [`PipelineMode::Direct`].
#[non_exhaustive]
#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DisplaySettings {
    /// Which render pipeline runs. Default: [`PipelineMode::Hdr`].
    pub mode: PipelineMode,
    /// Exposure model applied to linear radiance before tone mapping. Default:
    /// neutral ([`ExposureMode::NEUTRAL`]).
    pub exposure: ExposureSettings,
    /// Tone-map operator mapping exposed HDR radiance into display range.
    /// Default: [`ToneMapping::KhronosNeutral`].
    pub operator: ToneMapping,
}

impl Default for DisplaySettings {
    fn default() -> Self {
        Self {
            mode: PipelineMode::Hdr,
            exposure: ExposureSettings::default(),
            operator: ToneMapping::default(),
        }
    }
}

impl DisplaySettings {
    /// True when the full HDR pipeline is active (i.e. not [`PipelineMode::Direct`]).
    pub fn is_hdr(&self) -> bool {
        matches!(self.mode, PipelineMode::Hdr)
    }
}

/// Post-processing effects for the HDR render pipeline.
///
/// Passed via `EffectsFrame::post_process` each frame. Every effect here requires
/// the HDR pipeline ([`PipelineMode::Hdr`], set on
/// `EffectsFrame::display`); on [`PipelineMode::Direct`]
/// the viewport renders directly to the output surface and these are all ignored.
#[non_exhaustive]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PostProcessSettings {
    /// Enable screen-space ambient occlusion.
    pub ssao: bool,
    /// Bloom (glow) settings.
    pub bloom: BloomSettings,
    /// Enable FXAA (Fast Approximate Anti-Aliasing) fullscreen pass.
    pub fxaa: bool,
    /// Supersampling anti-aliasing factor. 1 = off, 2 = 2x, 4 = 4x.
    ///
    /// When `> 1`, scene geometry is rendered at `ssaa_factor x resolution` and
    /// downsampled before post-processing. Produces sharper edges than FXAA at
    /// the cost of rendering `ssaa_factor^2` times more pixels. Intended for
    /// offline or screenshot use, not interactive rendering.
    pub ssaa_factor: u32,
    /// Screen-space contact shadow settings.
    pub contact_shadows: ContactShadowSettings,
    /// Eye-Dome Lighting (depth-discontinuity darkening) settings.
    pub edl: EdlSettings,
    /// Depth-of-field bokeh settings.
    pub dof: DofSettings,
}

impl Default for PostProcessSettings {
    fn default() -> Self {
        Self {
            ssao: false,
            bloom: BloomSettings::default(),
            fxaa: false,
            ssaa_factor: 1,
            contact_shadows: ContactShadowSettings::default(),
            edl: EdlSettings::default(),
            dof: DofSettings::default(),
        }
    }
}

/// Bloom (glow) settings, grouped on [`PostProcessSettings::bloom`].
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BloomSettings {
    /// Enable bloom. Default: `false`.
    pub enabled: bool,
    /// HDR luminance threshold for bloom extraction. Default: `1.0`.
    pub threshold: f32,
    /// Bloom contribution multiplier. Default: `0.1`.
    pub intensity: f32,
    /// Firefly cap for bloom extraction: each pixel's luminance is scaled
    /// down to at most this value before thresholding, so a single very
    /// bright HDR texel (a tight specular highlight) cannot bloom into a
    /// large blob after the blur chain. Default: `4.0`. Set to `f32::MAX`
    /// to disable the cap.
    pub max_brightness: f32,
}

impl Default for BloomSettings {
    fn default() -> Self {
        Self {
            enabled: false,
            threshold: 1.0,
            intensity: 0.1,
            max_brightness: 4.0,
        }
    }
}

/// Screen-space contact shadow settings, grouped on
/// [`PostProcessSettings::contact_shadows`].
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ContactShadowSettings {
    /// Enable screen-space contact shadows (thin shadows at object-ground contact).
    pub enabled: bool,
    /// Maximum ray-march distance in view space. Default: `0.5`.
    pub max_distance: f32,
    /// Number of ray-march steps. Default: `16`.
    pub steps: u32,
    /// Depth thickness threshold for occlusion test. Default: `0.1`.
    pub thickness: f32,
}

impl Default for ContactShadowSettings {
    fn default() -> Self {
        Self {
            enabled: false,
            max_distance: 0.5,
            steps: 16,
            thickness: 0.1,
        }
    }
}

/// Eye-Dome Lighting settings, grouped on [`PostProcessSettings::edl`].
///
/// Samples a ring of 8 depth neighbours and darkens pixels at depth
/// discontinuities, making point clouds and surface edges easier to read at any
/// viewing distance.
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EdlSettings {
    /// Enable Eye-Dome Lighting depth enhancement.
    pub enabled: bool,
    /// EDL sample ring radius in pixels. Default: `1.0`.
    pub radius: f32,
    /// EDL darkening strength (0.0 = none, higher = stronger). Default: `1.0`.
    pub strength: f32,
}

impl Default for EdlSettings {
    fn default() -> Self {
        Self {
            enabled: false,
            radius: 1.0,
            strength: 1.0,
        }
    }
}

/// Depth-of-field bokeh settings, grouped on [`PostProcessSettings::dof`].
///
/// Pixels whose linearised depth is outside
/// `[focal_distance - focal_range, focal_distance + focal_range]` are blurred
/// with a disc kernel whose radius scales up to `max_blur_radius` pixels.
#[non_exhaustive]
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DofSettings {
    /// Enable depth of field bokeh blur.
    pub enabled: bool,
    /// View-space depth of the in-focus plane (same units as the scene). Default: `5.0`.
    pub focal_distance: f32,
    /// Half-width of the sharp band around the focal plane (view-space units). Default: `1.0`.
    pub focal_range: f32,
    /// Maximum blur kernel radius in pixels at maximum defocus. Default: `8.0`.
    pub max_blur_radius: f32,
}

impl Default for DofSettings {
    fn default() -> Self {
        Self {
            enabled: false,
            focal_distance: 5.0,
            focal_range: 1.0,
            max_blur_radius: 8.0,
        }
    }
}

#[cfg(test)]
mod exposure_tests {
    use super::*;

    fn approx(a: f32, b: f32, eps: f32) -> bool {
        (a - b).abs() <= eps
    }

    #[test]
    fn physical_ev100_matches_hand_computed() {
        // Reference exposure (f/1, 1s, ISO 100) is EV 0.
        assert!(approx(ev100_from_physical(1.0, 1.0, 100.0), 0.0, 1e-4));
        // Stopping down two stops (f/2) adds 2 EV.
        assert!(approx(ev100_from_physical(2.0, 1.0, 100.0), 2.0, 1e-4));
        // Doubling ISO (200) removes one stop.
        assert!(approx(ev100_from_physical(2.0, 1.0, 200.0), 1.0, 1e-4));
        // Halving the shutter (1/2 s) adds one stop.
        assert!(approx(ev100_from_physical(1.0, 0.5, 100.0), 1.0, 1e-4));
    }

    #[test]
    fn sunny_sixteen_is_about_ev15() {
        // Sunny 16: f/16 at shutter ~= 1/ISO. At ISO 100, 1/125s ~= EV 15.
        let ev = ev100_from_physical(16.0, 1.0 / 125.0, 100.0);
        assert!(approx(ev, 15.0, 0.1), "sunny-16 EV100 was {ev}");
    }

    #[test]
    fn ev0_is_unit_multiplier() {
        // The neutral boost is chosen so EV 0 lands on a 1.0 multiplier,
        // keeping exposure neutral. It goes away once lights carry
        // photometric units.
        assert!(approx(ev100_to_exposure(0.0), 1.0, 1e-4));
    }

    #[test]
    fn exposure_halves_per_stop_and_is_monotonic() {
        let e0 = ev100_to_exposure(0.0);
        let e1 = ev100_to_exposure(1.0);
        let e2 = ev100_to_exposure(2.0);
        // Each +1 EV halves the multiplier (darker).
        assert!(approx(e1, e0 * 0.5, 1e-4));
        assert!(approx(e2, e0 * 0.25, 1e-4));
        assert!(e2 < e1 && e1 < e0);
    }

    #[test]
    fn compensation_brightens() {
        let base = ExposureSettings::manual(0.0);
        let plus = ExposureSettings {
            mode: ExposureMode::Manual { ev: 0.0 },
            compensation: 1.0,
        };
        // +1 stop of compensation doubles the exposure multiplier.
        let b = base.manual_multiplier().unwrap();
        let p = plus.manual_multiplier().unwrap();
        assert!(approx(p, b * 2.0, 1e-4), "b={b} p={p}");
    }

    #[test]
    fn automatic_has_no_manual_multiplier() {
        let auto = ExposureSettings::automatic();
        assert!(auto.manual_multiplier().is_none());
        assert!(auto.base_ev100().is_none());
        assert!(matches!(auto.mode, ExposureMode::Automatic(_)));
    }

    #[test]
    fn physical_mode_multiplier_tracks_ev() {
        // f/2, 1s, ISO 100 -> EV 2 -> exposure = ev0 * 0.25.
        let s = ExposureSettings::physical(2.0, 1.0, 100.0);
        let expected = ev100_to_exposure(2.0);
        assert!(approx(s.manual_multiplier().unwrap(), expected, 1e-4));
    }
}