Skip to main content

AutoExposure

Struct AutoExposure 

Source
pub struct AutoExposure {
    pub stops: f32,
    pub middle_grey: f32,
    pub max: f32,
    pub min: f32,
    pub meter: ExposureMeter,
    pub brighten_speed: f32,
    pub darken_speed: f32,
    pub frozen: bool,
}
Expand description

The camera’s automatic exposure: the frame’s light is metered (ExposureMeter), compared with middle grey, and the exposure moved from stops against the difference, by at most max stops down and -min stops up, approaching those bounds smoothly (AutoExposure::correction). The scene is shown at 2^(stops - correction) times its light before any tone curve (AutoExposure::scale).

Light is metered in the world’s light unit: where core.directional_light_unit states one, a frame lit in lux is metered at lux divided by its lux_per_unit (the source’s own radiance unit, which middle_grey is in); where it states none, in lux. A renderer whose frame differs from the source’s (another sky, other lights) meters another value, and so settles at another exposure, for that stated reason.

The metered value adapts over time (AutoExposure::adapt); a still frame is shown at the adaptation’s fixed point, where the adapted value equals the frame’s metered one.

Fields§

§stops: f32

The exposure, in stops, of a frame metered at middle grey.

§middle_grey: f32

The metered value a frame is shown at stops for: a log2 luminance in the world’s light unit.

§max: f32

The most the exposure is lowered for a frame brighter than middle grey, in stops; at least 0.

§min: f32

The most it is raised for a darker frame, as a negative number of stops (the source’s minimum); at most 0.

§meter: ExposureMeter

How the frame’s light is metered.

§brighten_speed: f32

How fast the adapted value rises towards a brighter frame’s metered value: per dt seconds it moves the fraction 1 - 10^(-speed * dt) of the way. At least 0.

§darken_speed: f32

How fast it falls towards a darker frame’s, the same way. At least 0.

§frozen: bool

The adaptation is held: the exposure is stops, whatever the frame.

Implementations§

Source§

impl AutoExposure

Source

pub fn correction(&self, x: f32) -> f32

The stops the exposure is lowered by for a frame metered x above middle grey (negative: raised): max (1 - e^(-x / max)) for x > 0, min (1 - e^(-x / min)) for x < 0, 0 at 0, where that bound is 0, or where the adaptation is held. It follows x with slope 1 near 0 and approaches max above and min below.

Source

pub fn scale(&self, adapted: f32) -> f32

The factor the scene’s light is shown at for a frame whose adapted metered value is adapted.

Source

pub fn adapt(&self, adapted: f32, target: f32, dt: f32) -> f32

The adapted value after dt seconds at a frame metered target, from adapted. adapted == target is the fixed point: the value a still frame settles at.

Trait Implementations§

Source§

impl Clone for AutoExposure

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AutoExposure

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AutoExposure

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for AutoExposure

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for AutoExposure

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.