-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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:
good-web-game/src/graphics/shader.rs
Lines 35 to 100 in d46b338
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".
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working