Player
Player copied to clipboard
Additive and substractive picture support
With RPG Maker XP & Vx ace there was an added to show pictures additives and substractives.
In Rpg maker 2003 with dynrpg there's a plugin that support it: https://rpgmaker.net/engines/rt2k3/utilities/11/
Actual comparison of a light in player using alpha channel (that looks like similar to the own rpg maker pictures with transparency) and additive light of blending plugin with dynrpg
Looks like thie Enhancement has unlikely conflicts with existing games (is file ending based, .xxx.png).
And is fast because is only required once on load. Related pixman ops: OP_ADD, OP_SATURATE, OP_MULTIPLY
Can @gadesx explain why the pictures are displayed with 50% transparency and faded out in RPG_RT? EasyRPG starts with 100% transparency and the editor shows it the same way.
Looks DynRPG specific, doesn't happen when I replace the RPG_RT m(
Added a image here with the light I used as example,
the plugin ignore the colours like black, adding only
brighter colours of below.
Last year @elsemieni tried to implement this feature but had some differences in behavior (layering, etc.) that could require diving deeper to match existing RPG_RT patches, however looks great to start with: https://github.com/EasyRPG/Player/commit/ff64fd8c6033a73b64d6e02b5c23930e14118504
Maniac patch has also support for some of the blend modes
Fixed by #2628
Because this is powered by Pixman it also supports 32 bit PNGs with Alpha channel properly (Contrary to Maniac Patch which only has limited alpha channel support)
Pixman doesn't support the (odd) subtract blend mode though.
yeah it only supports "Difference". Defined as abs(xB−xA)
, so the behaviour is different (wraparound)
Potential patch:
diff --git a/src/sprite.cpp b/src/sprite.cpp
index 16203e9fc..377c03819 100644
--- a/src/sprite.cpp
+++ b/src/sprite.cpp
@@ -114,11 +114,43 @@ BitmapRef Sprite::Refresh(Rect& rect) {
}
void Sprite::SetBitmap(BitmapRef const& nbitmap) {
+ if (nbitmap == bitmap) {
+ return;
+ }
+
bitmap = nbitmap;
if (!bitmap) {
src_rect = Rect();
} else {
src_rect = bitmap->GetRect();
+
+ // EasyRPG Extension: Set the Blend Mode based on the filename, e.g. ".add.png" for "Additive"
+ SetBlendType(0);
+ StringView filename = bitmap->GetFilename();
+ if (filename.size() >= 8 && filename[filename.size() - 4] == '.' && filename[filename.size() - 8] == '.') {
+ filename = filename.substr(filename.size() - 7, 3);
+ constexpr std::array<std::pair<StringView, Bitmap::BlendMode>, 13> exts = {{
+ {"add", Bitmap::BlendMode::Additive},
+ {"clb", Bitmap::BlendMode::ColorBurn},
+ {"cld", Bitmap::BlendMode::ColorDodge},
+ {"dif", Bitmap::BlendMode::Difference},
+ {"drk", Bitmap::BlendMode::Darken},
+ {"exc", Bitmap::BlendMode::Exclusion},
+ {"hlg", Bitmap::BlendMode::HardLight},
+ {"lgh", Bitmap::BlendMode::Lighten},
+ {"mul", Bitmap::BlendMode::Multiply},
+ {"ove", Bitmap::BlendMode::Overlay},
+ {"sat", Bitmap::BlendMode::Saturate},
+ {"slg", Bitmap::BlendMode::SoftLight},
+ {"xor", Bitmap::BlendMode::XOR}
+ }};
+ auto it = std::lower_bound(exts.begin(), exts.end(), filename, [](const auto& e, const auto& fname) {
+ return e.first < fname;
+ });
+ if (it != exts.end() && it->first == filename) {
+ SetBlendType((int)it->second);
+ }
+ }
}
src_rect_effect = src_rect;
diff --git a/src/sprite_picture.cpp b/src/sprite_picture.cpp
index 58f094132..8c005c371 100644
--- a/src/sprite_picture.cpp
+++ b/src/sprite_picture.cpp
@@ -144,7 +144,9 @@ void Sprite_Picture::Draw(Bitmap& dst) {
SetFlipX(data.easyrpg_flip_horizontal);
SetFlipY(data.easyrpg_flip_vertical);
- SetBlendType(data.easyrpg_blend_mode);
+ if (static_cast<Bitmap::BlendMode>(data.easyrpg_blend_mode) != Bitmap::BlendMode::Default) {
+ SetBlendType(data.easyrpg_blend_mode);
+ }
Sprite::Draw(dst);
}
--