Here are both blend_modes examples. Top is ggez, bottom is good-web-game:

For some reason the blend modes behave differently, though they should be the same.
- ggez's blend modes: https://github.com/ggez/ggez/blob/f85d89a7dd2803c1f0e79543dc5f6076c4bbde8d/src/graphics/shader.rs#L80-L160
- gwg's blend modes:
|
impl From<BlendMode> for (BlendState, BlendState) { |
|
fn from(bm: BlendMode) -> Self { |
|
match bm { |
|
BlendMode::Add => ( |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::Value(BlendValue::SourceAlpha), |
|
BlendFactor::One, |
|
), |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::Value(BlendValue::SourceAlpha), |
|
BlendFactor::One, |
|
), |
|
), |
|
BlendMode::Subtract => ( |
|
BlendState::new( |
|
Equation::ReverseSubtract, |
|
BlendFactor::Value(BlendValue::SourceAlpha), |
|
BlendFactor::One, |
|
), |
|
BlendState::new(Equation::Add, BlendFactor::Zero, BlendFactor::One), |
|
), |
|
BlendMode::Alpha => ( |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::Value(BlendValue::SourceAlpha), |
|
BlendFactor::OneMinusValue(BlendValue::SourceAlpha), |
|
), |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::OneMinusValue(BlendValue::DestinationAlpha), |
|
BlendFactor::One, |
|
), |
|
), |
|
BlendMode::Premultiplied => ( |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::One, |
|
BlendFactor::OneMinusValue(BlendValue::SourceAlpha), |
|
), |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::OneMinusValue(BlendValue::DestinationAlpha), |
|
BlendFactor::One, |
|
), |
|
), |
|
BlendMode::Multiply => ( |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::Value(BlendValue::DestinationColor), |
|
BlendFactor::Zero, |
|
), |
|
BlendState::new( |
|
Equation::Add, |
|
BlendFactor::Value(BlendValue::DestinationAlpha), |
|
BlendFactor::Zero, |
|
), |
|
), |
|
BlendMode::Replace => ( |
|
BlendState::new(Equation::Add, BlendFactor::One, BlendFactor::Zero), |
|
BlendState::new(Equation::Add, BlendFactor::One, BlendFactor::Zero), |
|
), |
|
} |
|
} |
|
} |
The first step to analyzing this might be calculating some colors by hand using these formulas to then check whether one of the two cases actually produces this expected result. This would at least give us an answer to which of the two is actually "correct".
Here are both
blend_modesexamples. Top is ggez, bottom is good-web-game:For some reason the blend modes behave differently, though they should be the same.
good-web-game/src/graphics/shader.rs
Lines 35 to 100 in d46b338
The first step to analyzing this might be calculating some colors by hand using these formulas to then check whether one of the two cases actually produces this expected result. This would at least give us an answer to which of the two is actually "correct".