diff --git a/src/graphics/render/BlockWrapsRenderer.cpp b/src/graphics/render/BlockWrapsRenderer.cpp index c286e28ce..edf2625bf 100644 --- a/src/graphics/render/BlockWrapsRenderer.cpp +++ b/src/graphics/render/BlockWrapsRenderer.cpp @@ -57,7 +57,9 @@ void BlockWrapsRenderer::draw(BlockWrapper& wrapper, const Texture* texture) { glm::vec4 light(1, 1, 1, 0); if (wrapper.emission < 1.0f) { light = Lightmap::extractNormalized(chunks.getLight(wrapper.position)); - light = wrapper.emission + (1.0f - light); + light.r += wrapper.emission; + light.g += wrapper.emission; + light.b += wrapper.emission; } switch (wrapper.modelType) { case BlockModelType::BLOCK: @@ -150,11 +152,13 @@ void BlockWrapsRenderer::draw(const DrawContext& pctx, const Player& player) { } u64id_t BlockWrapsRenderer::add( - const glm::ivec3& position, const std::string& texture + const glm::ivec3& position, const std::string& texture, float emission ) { u64id_t id = nextWrapper++; wrappers[id] = std::make_unique(BlockWrapper { - position, {texture, texture, texture, texture, texture, texture}}); + position, + {texture, texture, texture, texture, texture, texture}, + emission}); return id; } diff --git a/src/graphics/render/BlockWrapsRenderer.hpp b/src/graphics/render/BlockWrapsRenderer.hpp index 2d14e4a93..84f7f5b91 100644 --- a/src/graphics/render/BlockWrapsRenderer.hpp +++ b/src/graphics/render/BlockWrapsRenderer.hpp @@ -22,7 +22,7 @@ class DrawContext; struct BlockWrapper { glm::ivec3 position; std::array textureFaces {}; - float emission = 1.0f; + float emission = 0.0f; // --- render cache --- util::TextureRegion texRegions[6] {}; @@ -53,7 +53,9 @@ public: void draw(const DrawContext& ctx, const Player& player); - u64id_t add(const glm::ivec3& position, const std::string& texture); + u64id_t add( + const glm::ivec3& position, const std::string& texture, float emission + ); BlockWrapper* get(u64id_t id) const; diff --git a/src/logic/scripting/lua/libs/libblockwraps.cpp b/src/logic/scripting/lua/libs/libblockwraps.cpp index 30aaa60c6..d4f937ac5 100644 --- a/src/logic/scripting/lua/libs/libblockwraps.cpp +++ b/src/logic/scripting/lua/libs/libblockwraps.cpp @@ -9,9 +9,10 @@ using namespace scripting; static int l_wrap(lua::State* L) { auto position = lua::tovec3(L, 1); std::string texture = lua::require_string(L, 2); + float emission = lua::isnumber(L, 3) ? lua::tonumber(L, 3) : 1.0f; return lua::pushinteger( - L, renderer->blockWraps->add(position, std::move(texture)) + L, renderer->blockWraps->add(position, std::move(texture), emission) ); }