diff options
| author | HampusM <hampus@hampusmat.com> | 2026-06-01 17:00:40 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-06-01 17:00:40 +0200 |
| commit | 76b84cc648ff2bcb2bf2f504e4c5b36d47e72684 (patch) | |
| tree | e1ace98dfb92bac779137df9be184e49905ec039 /engine/src/rendering/blending.rs | |
| parent | 8d5668151c3efbb757c4421a9fe35e2c35cbd992 (diff) | |
refactor(engine): rename 'renderer' module to 'rendering'
Diffstat (limited to 'engine/src/rendering/blending.rs')
| -rw-r--r-- | engine/src/rendering/blending.rs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/engine/src/rendering/blending.rs b/engine/src/rendering/blending.rs new file mode 100644 index 0000000..9ae2f82 --- /dev/null +++ b/engine/src/rendering/blending.rs @@ -0,0 +1,89 @@ +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Config +{ + pub source_factor: Factor, + pub destination_factor: Factor, + pub equation: Equation, +} + +impl Default for Config +{ + fn default() -> Self + { + Self { + source_factor: Factor::One, + destination_factor: Factor::Zero, + equation: Equation::default(), + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[non_exhaustive] +pub enum Factor +{ + /// Factor will be the RGBA color `(0,0,0,0)` + Zero, + + /// Factor will be the RGBA color `(1,1,1,1)` + One, + + /// Factor will be the source color + SrcColor, + + /// Factor will be the RGBA color `(1,1,1,1) - source color` + OneMinusSrcColor, + + /// Factor will be the destination color + DstColor, + + /// Factor will be the RGBA color `(1,1,1,1) - destination color` + OneMinusDstColor, + + /// Factor will be the alpha component of the source color. + SrcAlpha, + + /// Factor will be the RGBA color `(1,1,1,1) - source color alpha` + OneMinusSrcAlpha, + + /// Factor will be the alpha component of the destination color. + DstAlpha, + + /// Factor will be the RGBA color `(1,1,1,1) - destination color alpha` + OneMinusDstAlpha, + + /// Factor will be the constant color + ConstantColor, + + /// Factor will be the RGBA color `(1,1,1,1) - constant color` + OneMinusConstantColor, + + /// Factor will be the alpha component of the constant color. + ConstantAlpha, + + /// Factor will be the RGBA color `(1,1,1,1) - constant color alpha` + OneMinusConstantAlpha, +} + +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub enum Equation +{ + /// The destination color and source color is added to each other in the blend + /// function + #[default] + Add, + + /// The destination color is subtracted from the source color in the blend function + Subtract, + + /// The source color is subtracted from the destination color in the blend function + ReverseSubtract, + + /// The blend function will take the component-wise minimum of the destination color + /// and the source color + Min, + + /// The blend function will take the component-wise maximum of the destination color + /// and the source color + Max, +} |
