pub struct SpectralContext { /* private fields */ }Expand description
Everything the spectral exposure needs, built once per render.
Implementations§
Source§impl SpectralContext
impl SpectralContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Build the context on the internal grid, with the default camera profile and the default film’s layers.
The film’s layers are measured from the manufacturer’s data sheet; the
camera is CameraProfile::default, the input’s own definition. Both
are ordered R, G, B, and getting that order wrong is invisible until a
red patch comes out blue.
This is the context for whichever stock crate::RenderParams::default
uses. A render of any other film wants Self::for_stock, or the
exposure is computed with VISION3’s spectral response and only the curve
changes.
§Panics
Cannot panic: the grid is a compile-time constant with a valid step.
Sourcepub fn for_stock(stock: &FilmStock) -> Self
pub fn for_stock(stock: &FilmStock) -> Self
The context for a particular film stock: its own layer sensitivities.
This is the difference between “a film with a different curve” and “a different film”: which wavelengths each layer records decides how the scene separates into dyes, and no curve can stand in for it.
Sourcepub fn with_atoms(self, atoms: &[Spectrum]) -> Self
pub fn with_atoms(self, atoms: &[Spectrum]) -> Self
Use a dictionary prior, with the polynomial as the fallback.
Atoms are resampled onto the internal grid, so callers can pass spectra measured on any uniform grid.
Sourcepub fn with_camera(self, camera: CameraProfile) -> Self
pub fn with_camera(self, camera: CameraProfile) -> Self
Replace the camera assumption.
The grey anchor is recomputed, because it is the film’s response to the spectrum this camera reconstructs for mid grey. Changing the camera without that would silently re-balance every print.
Sourcepub fn with_threshold(self, threshold: f64) -> Self
pub fn with_threshold(self, threshold: f64) -> Self
Relative camera-response residual above which the hybrid falls back.
Sourcepub fn has_dictionary(&self) -> bool
pub fn has_dictionary(&self) -> bool
Whether a dictionary prior is active.
Sourcepub fn identity(&self) -> String
pub fn identity(&self) -> String
A stable description of the model this context implements.
Recorded in baked tables so that loading a table baked for a different camera or film fails loudly instead of silently producing wrong colour.
Sourcepub fn reference(&self) -> [f64; 3]
pub fn reference(&self) -> [f64; 3]
The film’s response to a reconstructed 18 % grey, per layer.
The anchor Self::expose divides by: an integrator that wants the
same anchor needs this number rather than a second reconstruction.
Sourcepub fn model(&self) -> Option<ExposureModel>
pub fn model(&self) -> Option<ExposureModel>
The constants this context integrates with, flattened for another backend.
None when a dictionary prior is active, or when a table is not on the
model’s grid. Both mean the closed form below is not what this context
computes, and a backend that rendered anyway would be rendering a
different model without saying so.
Sourcepub fn expose(&self, linear: [f64; 3]) -> Option<[f64; 3]>
pub fn expose(&self, linear: [f64; 3]) -> Option<[f64; 3]>
Per-layer log10 exposure for a linear-light pixel.
Returns None if the reconstruction fails, which can only happen on a
grid mismatch that Self::new rules out.
Sourcepub fn expose_with_extra(
&self,
linear: [f64; 3],
) -> Option<([f64; 3], Option<f64>)>
pub fn expose_with_extra( &self, linear: [f64; 3], ) -> Option<([f64; 3], Option<f64>)>
The same exposure, plus the fourth layer when the film has one.
One reconstruction feeds all four integrals: the second cyan emulsion sits in the same stack and sees the same light, so rebuilding the spectrum for it would be the same arithmetic twice.
The fourth layer is normalised on the blue layer’s grey response, not on its own. The data sheet plots every emulsion on one log H axis, so the distance between the blue-sensitive curve and the cyan-sensitive one is a speed difference; anchoring each on its own grey would divide that difference out and make the fourth layer a copy of the third.
Trait Implementations§
Source§impl Clone for SpectralContext
impl Clone for SpectralContext
Source§impl Debug for SpectralContext
impl Debug for SpectralContext
Auto Trait Implementations§
impl Forget for SpectralContext
impl Freeze for SpectralContext
impl Move for SpectralContext
impl RefUnwindSafe for SpectralContext
impl Send for SpectralContext
impl Sync for SpectralContext
impl Unpin for SpectralContext
impl UnsafeUnpin for SpectralContext
impl UnwindSafe for SpectralContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more