[][src]Struct web_glitz::pipeline::graphics::Blending

pub struct Blending {
    pub constant_color: [f32; 4],
    pub source_color_factor: BlendFactor,
    pub source_alpha_factor: BlendFactor,
    pub destination_color_factor: BlendFactor,
    pub destination_alpha_factor: BlendFactor,
    pub color_equation: BlendEquation,
    pub alpha_equation: BlendEquation,
}

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:

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 by 1 - R_c, where R_c is the value of the red component of the [constant_color].
  • BlendFactor::OneMinusConstantAlpha: all color components are multiplied by 1 - A_c, where A_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 by 1 - R_s, where R_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 by 1 - R_d, where R_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, where A_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, where A_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 or 1 - A_d, where A_s is the value of the alpha component of the source color and A_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

Blanket Implementations

impl<D, T> IntoBuffer<T> for D where
    D: Borrow<T> + 'static,
    T: Copy + 'static, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]