Skip to main content

Optics

Enum Optics 

Source
pub enum Optics {
    LensFlare {
        center: Point,
        ghosts: u8,
        threshold: f64,
        intensity: f64,
        tint: Color,
    },
    Lens {
        distortion: f64,
        chromatic: f64,
        auto_fit: bool,
        center: Option<Point>,
    },
    LensVignette {
        angle_of_view: f64,
        strength: f64,
        roundness: f64,
    },
    Bokeh {
        radius: f64,
        shape: ApertureShape,
        highlight_boost: f64,
    },
    RadialBlur {
        center: Point,
        strength: f64,
        samples: u8,
        decay: f64,
    },
    Anamorphic {
        threshold: f64,
        length: f64,
        stretch: f64,
        tint: Color,
        intensity: f64,
    },
    Relight {
        height_from: HeightFrom,
        light_dir: [f64; 3],
        color: Color,
        ambient: f64,
        specular: f64,
    },
}
Expand description

Opt-in spatial effects on a completed subtree.

Variants§

§

LensFlare

Mirrored bright-source ghosts plus a restrained radial halo.

Fields

§center: Point

Local optical center.

§ghosts: u8

Ghost count, in 1..=8.

§threshold: f64

Nonnegative highlight cutoff.

§intensity: f64

Nonnegative added-energy multiplier.

§tint: Color

Encoded-sRGB ghost tint.

§

Lens

Radial distortion and channel-dependent radial dispersion.

Fields

§distortion: f64

Distortion coefficient, in -0.3..=1.

§chromatic: f64

Dispersion coefficient, in -0.1..=0.1.

§auto_fit: bool

Shrinks sample coordinates to avoid corner holes.

§center: Option<Point>

Local center; None uses effect bounds.

§

LensVignette

Physical cos^4 falloff.

Fields

§angle_of_view: f64

Full diagonal field of view, in (0, 170) degrees.

§strength: f64

Effect strength, in 0..=1.

§roundness: f64

Zero elliptical, one circular.

§

Bokeh

Bounded aperture blur with highlight-weighted sampling. Small radii use fewer taps; see Optics::bokeh_taps.

Fields

§radius: f64

Local blur radius.

§shape: ApertureShape

Aperture footprint.

§highlight_boost: f64

Nonnegative highlight weighting.

§

RadialBlur

Bounded sampling from each pixel toward a light source.

Fields

§center: Point

Local light source position.

§strength: f64

Ray length fraction, in 0..=1.

§samples: u8

Number of taps, in 1..=64.

§decay: f64

Relative weight decay, in 0..=1.

§

Anamorphic

Anamorphic horizontal streak: highlights above threshold are stretched along the device X axis with a tinted Gaussian and added back to the source.

Fields

§threshold: f64

Nonnegative luminance cutoff applied to straight-linear highlights.

§length: f64

Horizontal streak standard deviation in local units.

§stretch: f64

Horizontal-to-vertical aspect ratio, in 1..=64; vertical sigma is length / stretch.

§tint: Color

Encoded-sRGB streak tint; its alpha is ignored.

§intensity: f64

Nonnegative added-energy multiplier.

§

Relight

Sobel height normals, Lambert diffuse and Blinn-Phong specular.

Fields

§height_from: HeightFrom

Height field source.

§light_dir: [f64; 3]

Finite nonzero direction toward the light.

§color: Color

Light color.

§ambient: f64

Nonnegative ambient multiplier.

§specular: f64

Nonnegative specular multiplier.

Implementations§

Source§

impl Optics

Source

pub fn validate(&self) -> Result<(), ValidationError>

Validates bounded finite parameters before capture or device initialization.

Source

pub fn device(&self, transform: Transform, scale: f64) -> Self

Maps local positions/radii to conservative device-space parameters.

Source

pub fn streak_sigmas(&self) -> Option<[f64; 2]>

Horizontal and vertical Gaussian sigmas of an anamorphic streak.

Source

pub fn bounds(&self, source: Rect) -> Rect

Conservative output support; radial optics retain the original frame bounds.

Source

pub fn bokeh_taps(radius: f64) -> u32

Aperture taps used for a Bokeh radius: ceil(1.4 * radius^2) within 8..=64, so tap spacing stays near 1.5 pixels until the 64-tap maximum. Non-finite radii use the maximum.

Source

pub fn parameters(&self, bounds: Rect) -> ([f64; 32], [[f32; 2]; 64])

Shared CPU/GPU numerical contract, with up to 64 deterministic aperture offsets. For Bokeh, values[3] holds the tap count and offsets past it are zero.

Trait Implementations§

Source§

impl Clone for Optics

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 Optics

Source§

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

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

impl PartialEq for Optics

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 StructuralPartialEq for Optics

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<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> 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.