thorvg: renderer: incorrect BlendMode behaviors
I’m currently trying to refactor the advanced color blending logic of the GL backend. I’m confused by some of Thorvg’s behaviors on color blending. The main problem is that I found that the behavior of blend mode is inconsistent when applied to a normal Shape or to a Scene. For example:
//Normal
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50);
shape1->fill(0, 255, 255);
shape1->blend(tvg::BlendMethod::Normal);
canvas->push(shape1);
// direct draw shape with blend mode
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 200, 200, 50, 50);
shape->fill(255, 255, 255, 250);
shape->blend(tvg::BlendMethod::ColorDodge);
canvas->push(shape);
This code get the following result:
But if put the shape inside a scene, even if the scene only contains one shape, like this:
//Normal
auto shape1 = tvg::Shape::gen();
shape1->appendRect(0, 0, 400, 400, 50, 50);
shape1->fill(0, 255, 255);
shape1->blend(tvg::BlendMethod::Normal);
canvas->push(shape1);
//ColorDodge On the scene
auto scene = tvg::Scene::gen();
scene->blend(tvg::BlendMethod::ColorDodge);
auto shape = tvg::Shape::gen();
shape->appendRect(0, 0, 200, 200, 50, 50);
shape->fill(255, 255, 255, 250);
scene->push(shape);
canvas->push(scene);
Got this result:
Some blend modes seem to draw nothing when DstColor is all zeros, and this behavior is different from skia or impeller or html & css. I’m going to align SKIA’s Blend behavior in the GL backend by following this reference : https://github.com/google/skia/blob/main/include/core/SkBlendMode.h
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 50 (27 by maintainers)
Commits related to this issue
- sw_engine: corrected blendings Corrected wrong ColorDodge, ColorBurn ColorExclusion blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings Corrected wrong ColorDodge, ColorBurn ColorExclusion blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings corrected wrong ColorDodge, ColorBurn, ColorExclusion blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- wg_engine: corrected ColorDodge, ColorBurn equation issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- wg_engine: corrected ColorDodge, ColorBurn equation issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- gl_engine: corrected ColorDodge, ColorBurn equation issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- gl_engine: corrected ColorDodge, ColorBurn equation issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet 2 years ago
- sw_engine: corrected blendings corrected wrong ColorDodge, ColorBurn, Exclusion, SoftLight blendings issue: https://github.com/thorvg/thorvg/issues/3072 — committed to mgrudzinska/thorvg by hermet 2 years ago
- gl_engine: corrected ColorDodge, ColorBurn equation issue: https://github.com/thorvg/thorvg/issues/3072 — committed to mgrudzinska/thorvg by hermet 2 years ago
- sw_engine: preserve source values in empty buffer tweak operations to better align with the desired standard behavior. issue: https://github.com/thorvg/thorvg/issues/3072 — committed to thorvg/thorvg by hermet a year ago
- sw_engine: tweak operations to better align with the designed bevaviors - presere source values in empty buffer - properly unpremultiply dst values before blending issue: https://github.com/thorvg/t... — committed to thorvg/thorvg by hermet a year ago
- sw_engine: tweak operations to better align with the designed bevaviors - presere source values in empty buffer - properly unpremultiply dst values before blending issue: https://github.com/thorvg/t... — committed to thorvg/thorvg by hermet a year ago
- sw_engine: tweak operations to better align with the designed bevaviors - presere source values in empty buffer - properly unpremultiply dst values before blending issue: https://github.com/thorvg/t... — committed to thorvg/thorvg by hermet a year ago
- sw_engine: tweak operations to better align with the designed bevaviors - presere source values in empty buffer - properly unpremultiply dst values before blending issue: https://github.com/thorvg/t... — committed to thorvg/thorvg by hermet a year ago
@hermet see this PR #3081