Skip to main content

ChromaKeyParams

Struct ChromaKeyParams 

Source
pub struct ChromaKeyParams {
    pub key_r: f32,
    pub key_g: f32,
    pub key_b: f32,
    pub similarity: f32,
    pub blend: f32,
    pub spill: f32,
    pub bg_r: f32,
    pub bg_g: f32,
    pub bg_b: f32,
    /* private fields */
}
Expand description

Parameters for chroma_key. Default keys a pure-green screen and composites the foreground over black.

similarity and blend use FFmpeg chromakey semantics on FFmpeg’s scale (the same RGB→CbCr coefficients and √(d²/2) normalization, so 1.0 spans the full CbCr plane diagonal): distance ≤ similarity is background, the next blend of distance ramps linearly to foreground, and blend ≈ 0 degenerates to a hard threshold. One structural difference: FFmpeg compares the source’s RAW chroma plane codes against a BT.601-converted key, while this shader decodes the pixel to RGB first and projects both sides through the one BT.601 conversion. The two agree (within quantization) only on full-range BT.601 input; on any other range/matrix combination FFmpeg’s raw-code comparison carries a small built-in bias this implementation does not reproduce — treat ported ffmpeg -vf chromakey=... values as a close starting point, not bit-identical.

Fields§

§key_r: f32

Key color red, 0.0..=1.0.

§key_g: f32

Key color green, 0.0..=1.0.

§key_b: f32

Key color blue, 0.0..=1.0.

§similarity: f32

Chroma distance keyed as background, 0.00001..=1.0. Larger keys more; neutral gray sits ≈ 0.38 from pure green on this scale.

§blend: f32

Width of the soft edge past similarity, 0.0..=1.0; 0.0 is a hard binary matte.

§spill: f32

Spill suppression strength, 0.0..=1.0: how strongly the key’s dominant channel is clamped toward the mean of the other two in surviving foreground (1.0 = FFmpeg despill defaults).

§bg_r: f32

Background red, 0.0..=1.0.

§bg_g: f32

Background green, 0.0..=1.0.

§bg_b: f32

Background blue, 0.0..=1.0.

Implementations§

Source§

impl ChromaKeyParams

Source

pub fn green_screen() -> Self

Keys a pure-green screen (#00FF00) over black.

Source

pub fn blue_screen() -> Self

Keys a pure-blue screen (#0000FF) over black.

Source

pub fn with_background(self, r: f32, g: f32, b: f32) -> Self

Replaces the background color the foreground is composited over.

Trait Implementations§

Source§

impl Clone for ChromaKeyParams

Source§

fn clone(&self) -> ChromaKeyParams

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 Copy for ChromaKeyParams

Source§

impl Debug for ChromaKeyParams

Source§

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

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

impl Default for ChromaKeyParams

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ChromaKeyParams

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Pod for ChromaKeyParams

Source§

impl StructuralPartialEq for ChromaKeyParams

Source§

impl Zeroable for ChromaKeyParams

Source§

fn zeroed() -> Self

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> AnyBitPattern for T
where T: Pod,

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> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> NoUninit for T
where T: Pod,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,