VkBlendOp
Once the source and destination blend factors have been selected, they along with the source and destination components are passed to the blending operations. RGB and alpha components can use different operations. Possible values of VkBlendOp, specifying the operations, are:
typedef enum VkBlendOp {
VK_BLEND_OP_ADD = 0,
VK_BLEND_OP_SUBTRACT = 1,
VK_BLEND_OP_REVERSE_SUBTRACT = 2,
VK_BLEND_OP_MIN = 3,
VK_BLEND_OP_MAX = 4,
// Provided by extensions
VK_BLEND_OP_ZERO_EXT = -999999000,
VK_BLEND_OP_SRC_EXT = -999999001,
VK_BLEND_OP_DST_EXT = -999999002,
VK_BLEND_OP_SRC_OVER_EXT = -999999003,
VK_BLEND_OP_DST_OVER_EXT = -999999004,
VK_BLEND_OP_SRC_IN_EXT = -999999005,
VK_BLEND_OP_DST_IN_EXT = -999999006,
VK_BLEND_OP_SRC_OUT_EXT = -999999007,
VK_BLEND_OP_DST_OUT_EXT = -999999008,
VK_BLEND_OP_SRC_ATOP_EXT = -999999009,
VK_BLEND_OP_DST_ATOP_EXT = -999999010,
VK_BLEND_OP_XOR_EXT = -999999011,
VK_BLEND_OP_MULTIPLY_EXT = -999999012,
VK_BLEND_OP_SCREEN_EXT = -999999013,
VK_BLEND_OP_OVERLAY_EXT = -999999014,
VK_BLEND_OP_DARKEN_EXT = -999999015,
VK_BLEND_OP_LIGHTEN_EXT = -999999016,
VK_BLEND_OP_COLORDODGE_EXT = -999999017,
VK_BLEND_OP_COLORBURN_EXT = -999999018,
VK_BLEND_OP_HARDLIGHT_EXT = -999999019,
VK_BLEND_OP_SOFTLIGHT_EXT = -999999020,
VK_BLEND_OP_DIFFERENCE_EXT = -999999021,
VK_BLEND_OP_EXCLUSION_EXT = -999999022,
VK_BLEND_OP_INVERT_EXT = -999999023,
VK_BLEND_OP_INVERT_RGB_EXT = -999999024,
VK_BLEND_OP_LINEARDODGE_EXT = -999999025,
VK_BLEND_OP_LINEARBURN_EXT = -999999026,
VK_BLEND_OP_VIVIDLIGHT_EXT = -999999027,
VK_BLEND_OP_LINEARLIGHT_EXT = -999999028,
VK_BLEND_OP_PINLIGHT_EXT = -999999029,
VK_BLEND_OP_HARDMIX_EXT = -999999030,
VK_BLEND_OP_HSL_HUE_EXT = -999999031,
VK_BLEND_OP_HSL_SATURATION_EXT = -999999032,
VK_BLEND_OP_HSL_COLOR_EXT = -999999033,
VK_BLEND_OP_HSL_LUMINOSITY_EXT = -999999034,
VK_BLEND_OP_PLUS_EXT = -999999035,
VK_BLEND_OP_PLUS_CLAMPED_EXT = -999999036,
VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT = -999999037,
VK_BLEND_OP_PLUS_DARKER_EXT = -999999038,
VK_BLEND_OP_MINUS_EXT = -999999039,
VK_BLEND_OP_MINUS_CLAMPED_EXT = -999999040,
VK_BLEND_OP_CONTRAST_EXT = -999999041,
VK_BLEND_OP_INVERT_OVG_EXT = -999999042,
VK_BLEND_OP_RED_EXT = -999999043,
VK_BLEND_OP_GREEN_EXT = -999999044,
VK_BLEND_OP_BLUE_EXT = -999999045,
} VkBlendOp;
pub struct BlendOp(u32);
impl BlendOp {
pub const ADD: Self = 0;
pub const SUBTRACT: Self = 1;
pub const REVERSE_SUBTRACT: Self = 2;
pub const MIN: Self = 3;
pub const MAX: Self = 4;
pub const ZERO_EXT: Self = -999999000;
pub const SRC_EXT: Self = -999999001;
pub const DST_EXT: Self = -999999002;
pub const SRC_OVER_EXT: Self = -999999003;
pub const DST_OVER_EXT: Self = -999999004;
pub const SRC_IN_EXT: Self = -999999005;
pub const DST_IN_EXT: Self = -999999006;
pub const SRC_OUT_EXT: Self = -999999007;
pub const DST_OUT_EXT: Self = -999999008;
pub const SRC_ATOP_EXT: Self = -999999009;
pub const DST_ATOP_EXT: Self = -999999010;
pub const XOR_EXT: Self = -999999011;
pub const MULTIPLY_EXT: Self = -999999012;
pub const SCREEN_EXT: Self = -999999013;
pub const OVERLAY_EXT: Self = -999999014;
pub const DARKEN_EXT: Self = -999999015;
pub const LIGHTEN_EXT: Self = -999999016;
pub const COLORDODGE_EXT: Self = -999999017;
pub const COLORBURN_EXT: Self = -999999018;
pub const HARDLIGHT_EXT: Self = -999999019;
pub const SOFTLIGHT_EXT: Self = -999999020;
pub const DIFFERENCE_EXT: Self = -999999021;
pub const EXCLUSION_EXT: Self = -999999022;
pub const INVERT_EXT: Self = -999999023;
pub const INVERT_RGB_EXT: Self = -999999024;
pub const LINEARDODGE_EXT: Self = -999999025;
pub const LINEARBURN_EXT: Self = -999999026;
pub const VIVIDLIGHT_EXT: Self = -999999027;
pub const LINEARLIGHT_EXT: Self = -999999028;
pub const PINLIGHT_EXT: Self = -999999029;
pub const HARDMIX_EXT: Self = -999999030;
pub const HSL_HUE_EXT: Self = -999999031;
pub const HSL_SATURATION_EXT: Self = -999999032;
pub const HSL_COLOR_EXT: Self = -999999033;
pub const HSL_LUMINOSITY_EXT: Self = -999999034;
pub const PLUS_EXT: Self = -999999035;
pub const PLUS_CLAMPED_EXT: Self = -999999036;
pub const PLUS_CLAMPED_ALPHA_EXT: Self = -999999037;
pub const PLUS_DARKER_EXT: Self = -999999038;
pub const MINUS_EXT: Self = -999999039;
pub const MINUS_CLAMPED_EXT: Self = -999999040;
pub const CONTRAST_EXT: Self = -999999041;
pub const INVERT_OVG_EXT: Self = -999999042;
pub const RED_EXT: Self = -999999043;
pub const GREEN_EXT: Self = -999999044;
pub const BLUE_EXT: Self = -999999045;
}
The semantics of the basic blend operations are described in the table below:
| VkBlendOp | RGB Components | Alpha Component |
|---|---|---|
VK_BLEND_OP_ADD | R = Rs0 × Sr + Rd × DrG = Gs0 × Sg + Gd × DgB = Bs0 × Sb + Bd × Db | A = As0 × Sa + Ad × Da |
VK_BLEND_OP_SUBTRACT | R = Rs0 × Sr - Rd × DrG = Gs0 × Sg - Gd × DgB = Bs0 × Sb - Bd × Db | A = As0 × Sa - Ad × Da |
VK_BLEND_OP_REVERSE_SUBTRACT | R = Rd × Dr - Rs0 × SrG = Gd × Dg - Gs0 × SgB = Bd × Db - Bs0 × Sb | A = Ad × Da - As0 × Sa |
VK_BLEND_OP_MIN | R = min(Rs0,Rd)G = min(Gs0,Gd)B = min(Bs0,Bd) | A = min(As0,Ad) |
VK_BLEND_OP_MAX | R = max(Rs0,Rd)G = max(Gs0,Gd)B = max(Bs0,Bd) | A = max(As0,Ad) |
In this table, the following conventions are used:
- Rs0, Gs0, Bs0 and As0 represent the first source color R, G, B, and A components, respectively.
- Rd, Gd, Bd and Ad represent the R, G, B, and A components of the destination color. That is, the color currently in the corresponding color attachment for this fragment/sample.
- Sr, Sg, Sb and Sa represent the source blend factor R, G, B, and A components, respectively.
- Dr, Dg, Db and Da represent the destination blend factor R, G, B, and A components, respectively.
The blending operation produces a new set of values R, G, B and A, which are written to the framebuffer attachment. If blending is not enabled for this attachment, then R, G, B and A are assigned Rs0, Gs0, Bs0 and As0, respectively.
If the color attachment is fixed-point, the components of the source and destination values and blend factors are each clamped to [0,1] or [-1,1] respectively for an unsigned normalized or signed normalized color attachment prior to evaluating the blend operations. If the color attachment is floating-point, no clamping occurs.