A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat: add Lighten, Darken, Overlay blend modes
esengine8714203a913a
diff --git a/src/esengine/renderer/BlendMode.hpp b/src/esengine/renderer/BlendMode.hppindex 7ce49592c..3e8e20195 100644--- a/src/esengine/renderer/BlendMode.hpp+++ b/src/esengine/renderer/BlendMode.hpp@@ -24,6 +24,9 @@ enum class BlendMode : u8 {Screen = 3, // One, OneMinusSrcColor (lighten)PremultipliedAlpha = 4, // One, OneMinusSrcAlpha (premultiplied alpha)PmaAdditive = 5, // One, One (additive with premultiplied alpha source)+ Lighten = 6, // GL_MAX blend equation (take brighter pixel)+ Darken = 7, // GL_MIN blend equation (take darker pixel)+ Overlay = 8, // Screen on light, Multiply on dark (requires shader)};} // namespace esenginediff --git a/src/esengine/renderer/GLDevice.cpp b/src/esengine/renderer/GLDevice.cppindex 022d364b2..f3327e406 100644--- a/src/esengine/renderer/GLDevice.cpp+++ b/src/esengine/renderer/GLDevice.cpp@@ -183,6 +183,21 @@ void GLDevice::setBlendMode(BlendMode mode) {case BlendMode::PmaAdditive:glBlendFuncSeparate(GL_ONE, GL_ONE, GL_ONE, GL_ONE);break;+ case BlendMode::Lighten:+ glBlendEquation(GL_MAX);+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);+ break;+ case BlendMode::Darken:+ glBlendEquation(GL_MIN);+ glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);+ break;+ case BlendMode::Overlay:+ glBlendFuncSeparate(GL_DST_COLOR, GL_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);+ break;+ }++ if (mode != BlendMode::Lighten && mode != BlendMode::Darken) {+ glBlendEquation(GL_FUNC_ADD);}}