[−][src]Struct web_glitz::pipeline::graphics::Blending
Provides instructions on how blending should be performed.
When Blending is enabled, a fragment's color output does not merely overwrite the color buffer's current color value for this fragment, but instead these two values are combined using a BlendEquation. The new color output for the fragment is referred to as the source color, the value already in the color buffer is referred to as the destination color. Separate blending equations may be used for the RGB portion and for the alpha portion of the color value; the respective blending equations are specified by [color_equation] and [alpha_equation]. The following blending equations are available:
- BlendEquation::Addition: the output of blending
O
is calculated asO = F_s * S + F_d * D
. - BlendEquation::Subtraction: the output of blending
O
is calculated asO = F_s * S - F_d * D
. - BlendEquation::ReverseSubtraction: the output of blending
O
is calculated asO = F_d * D - F_s * S
. - BlendEquation::Min: the output of blending
O
is calculated asO = min(F_d * D, F_s * S)
. - BlendEquation::Max: the output of blending
O
is calculated asO = max(F_d * D, F_s * S)
.
Here S
is the relevant portion of the source value: the [color_equation] will use the red,
green and blue components of the source color as S
, the [alpha_equation] will use the alpha
components of the source color as S
. D
is the relevant portion of the destination value: the
[color_function] will use the red, green and blue components of the destination color as D
and the [alpha_function] will use the alpha component of the destination color as D
. F_s
and
F_d
are BlendFactors for S
and D
respectively. The following blend factors are
available:
- BlendFactor::Zero: all color components are multiplied by
0
. - BlendFactor::One: all color components are multiplied by
1
. - BlendFactor::ConstantColor: the value of each color component is multiplied by the value or the corresponding component of the color specified by [constant_color].
- BlendFactor::OneMinusConstantColor: the value of each color component is multiplied by
the value of the corresponding component of the color specified by [constant_color],
subtracted from
1
. For example, the red component is multiplied by1 - R_c
, whereR_c
is the value of the red component of the [constant_color]. - BlendFactor::OneMinusConstantAlpha: all color components are multiplied by
1 - A_c
, whereA_c
is the value of the alpha component of the color specified by [constant_color]. - BlendFactor::SourceColor: the value of each color component is multiplied by the value of the corresponding component of the source color.
- BlendFactor::OneMinusSourceColor: the value of each color component is multiplied by the
value of the corresponding component of the source color subtracted from
1
. For example, the red component is multiplied by1 - R_s
, whereR_s
is the value of the red component of the source color. - BlendFactor::DestinationColor: the value of each color component is multiplied by the value of the corresponding component of the destination color.
- BlendFactor::OneMinusDestinationColor: the value of each color component is multiplied by
the value of the corresponding component of the destination color subtracted from
1
. For example, the red component is multiplied by1 - R_d
, whereR_d
is the value of the red component of the destination color. - BlendFactor::SourceAlpha: all color components are multiplied by the value of the alpha component of the source color.
- BlendFactor::OneMinusSourceAlpha: all color components are multiplied by
1 - A_s
, whereA_s
is the value of the alpha component of the source color. - BlendFactor::DestinationAlpha: all color components are multiplied by the value of the alpha component of the destination color.
- BlendFactor::OneMinusDestinationAlpha: all color components are multiplied by
1 - A_s
, whereA_s
is the value of the alpha component of the destination color. - BlendFactor::SourceAlphaSaturate: all color components are multiplied by the smaller of
either
A_s
or1 - A_d
, whereA_s
is the value of the alpha component of the source color andA_d
is the value of the alpha component of the destination color.
Blending may be instantiated with default values through Default:
use web_glitz::pipeline::graphics::{Blending, BlendEquation, BlendFactor}; assert_eq!(Blending::default(), Blending { constant_color: [0.0, 0.0, 0.0, 0.0], source_color_factor: BlendFactor::One, source_alpha_factor: BlendFactor::One, destination_color_factor: BlendFactor::Zero, destination_alpha_factor: BlendFactor::Zero, color_equation: BlendEquation::Addition, alpha_equation: BlendEquation::Addition });
Fields
constant_color: [f32; 4]
The color used as the constant color when BlendFactor::ConstantColor, BlendFactor::OneMinusConstantColor, BlendFactor::ConstantAlpha or BlendFactor::OneMinusConstantAlpha is used as a blending factor.
Component values are clamped to [0, 1]
.
This value is ignored when other BlendFactors are used.
source_color_factor: BlendFactor
The BlendFactor that the [color_equation] applies to the source value.
source_alpha_factor: BlendFactor
The BlendFactor that the [alpha_equation] applies to the source value.
destination_color_factor: BlendFactor
The BlendFactor that the [color_equation] applies to the destination value.
destination_alpha_factor: BlendFactor
The BlendFactor that the [alpha_equation] applies to the destination value.
color_equation: BlendEquation
The BlendFactor used to combine the red, green and blue components of the source and destination colors.
alpha_equation: BlendEquation
The BlendEquation used to combine the alpha components of the source and destination colors.
Trait Implementations
impl Default for Blending
[src]
impl Clone for Blending
[src]
impl PartialEq<Blending> for Blending
[src]
impl Debug for Blending
[src]
Auto Trait Implementations
impl Send for Blending
impl Unpin for Blending
impl Sync for Blending
impl UnwindSafe for Blending
impl RefUnwindSafe for Blending
Blanket Implementations
impl<D, T> IntoBuffer<T> for D where
D: Borrow<T> + 'static,
T: Copy + 'static,
[src]
D: Borrow<T> + 'static,
T: Copy + 'static,
fn into_buffer<Rc>(Self, &Rc, UsageHint) -> Buffer<T> where
Rc: RenderingContext + Clone + 'static,
[src]
Rc: RenderingContext + Clone + 'static,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,