diff --git a/src/client/lightview.cpp b/src/client/lightview.cpp index c63c20af..ff63c177 100644 --- a/src/client/lightview.cpp +++ b/src/client/lightview.cpp @@ -36,6 +36,7 @@ LightView::LightView() { m_lightbuffer = g_framebuffers.createFrameBuffer(); m_lightTexture = generateLightBubble(0.1f); + m_blendEquation = Painter::BlendEquation_Add; reset(); } @@ -87,6 +88,12 @@ void LightView::addLightSource(const Point& center, float scaleFactor, const Lig color.setGreen(color.gF() * brightness); color.setBlue(color.bF() * brightness); + if(m_blendEquation == Painter::BlendEquation_Add && m_lightMap.size() > 0) { + LightSource prevSource = m_lightMap.back(); + if(prevSource.center == center && prevSource.color == color && prevSource.radius == radius) + return; + } + LightSource source; source.center = center; source.color = color; @@ -126,7 +133,7 @@ void LightView::draw(const Rect& dest, const Rect& src) m_lightbuffer->bind(); g_painter->setCompositionMode(Painter::CompositionMode_Replace); drawGlobalLight(m_globalLight); - g_painter->setBlendEquation(Painter::BlendEquation_Max); + g_painter->setBlendEquation(m_blendEquation); g_painter->setCompositionMode(Painter::CompositionMode_Add); for(const LightSource& source : m_lightMap) drawLightSource(source.center, source.color, source.radius); diff --git a/src/client/lightview.h b/src/client/lightview.h index 8612d4f8..c14363e4 100644 --- a/src/client/lightview.h +++ b/src/client/lightview.h @@ -25,6 +25,7 @@ #include "declarations.h" #include +#include #include "thingtype.h" struct LightSource { @@ -44,11 +45,14 @@ public: void resize(const Size& size); void draw(const Rect& dest, const Rect& src); + void setBlendEquation(Painter::BlendEquation blendEquation) { m_blendEquation = blendEquation; } + private: void drawGlobalLight(const Light& light); void drawLightSource(const Point& center, const Color& color, int radius); TexturePtr generateLightBubble(float centerFactor); + Painter::BlendEquation m_blendEquation; TexturePtr m_lightTexture; FrameBufferPtr m_lightbuffer; Light m_globalLight; diff --git a/src/client/luafunctions.cpp b/src/client/luafunctions.cpp index 6f88e777..25b51356 100644 --- a/src/client/luafunctions.cpp +++ b/src/client/luafunctions.cpp @@ -565,6 +565,7 @@ void Client::registerLuaFunctions() g_lua.bindClassMemberFunction("setMapShader", &UIMap::setMapShader); g_lua.bindClassMemberFunction("setMinimumAmbientLight", &UIMap::setMinimumAmbientLight); g_lua.bindClassMemberFunction("setLimitVisibleRange", &UIMap::setLimitVisibleRange); + g_lua.bindClassMemberFunction("setAddLightMethod", &UIMap::setAddLightMethod); g_lua.bindClassMemberFunction("isMultifloor", &UIMap::isMultifloor); g_lua.bindClassMemberFunction("isAutoViewModeEnabled", &UIMap::isAutoViewModeEnabled); g_lua.bindClassMemberFunction("isDrawingTexts", &UIMap::isDrawingTexts); diff --git a/src/client/mapview.h b/src/client/mapview.h index 05b64a0b..6b8c8ca2 100644 --- a/src/client/mapview.h +++ b/src/client/mapview.h @@ -28,6 +28,7 @@ #include #include #include +#include "lightview.h" // @bindclass class MapView : public LuaObject @@ -110,6 +111,8 @@ public: void setAnimated(bool animated) { m_animated = animated; requestVisibleTilesCacheUpdate(); } bool isAnimating() { return m_animated; } + void setAddLightMethod(bool add) { m_lightView->setBlendEquation(add ? Painter::BlendEquation_Add : Painter::BlendEquation_Max); } + void setShader(const PainterShaderProgramPtr& shader, float fadein, float fadeout); PainterShaderProgramPtr getShader() { return m_shader; } diff --git a/src/client/uimap.h b/src/client/uimap.h index 6adbad4f..c3e8bd6f 100644 --- a/src/client/uimap.h +++ b/src/client/uimap.h @@ -59,6 +59,7 @@ public: void setMapShader(const PainterShaderProgramPtr& shader, float fadeout, float fadein) { m_mapView->setShader(shader, fadein, fadeout); } void setMinimumAmbientLight(float intensity) { m_mapView->setMinimumAmbientLight(intensity); } void setLimitVisibleRange(bool limitVisibleRange) { m_limitVisibleRange = limitVisibleRange; updateVisibleDimension(); } + void setAddLightMethod(bool add) { m_mapView->setAddLightMethod(add); } bool isMultifloor() { return m_mapView->isMultifloor(); } bool isAutoViewModeEnabled() { return m_mapView->isAutoViewModeEnabled(); }