diff --git a/include/llmr/style/properties.hpp b/include/llmr/style/properties.hpp index eae2351f4..655d6735a 100644 --- a/include/llmr/style/properties.hpp +++ b/include/llmr/style/properties.hpp @@ -131,6 +131,7 @@ struct TextClass { Color color = {{ 0, 0, 0, 1 }}; Color halo = {{ 1, 1, 1, 0.75 }}; FunctionProperty haloRadius = 0.25f; + FunctionProperty haloBlur = 1.0f; FunctionProperty size = 12.0f; FunctionProperty rotate = 0.0f; FunctionProperty alwaysVisible = false; @@ -144,6 +145,7 @@ struct TextProperties { Color color = {{ 0, 0, 0, 1 }}; Color halo = {{ 1, 1, 1, 0.75 }}; float haloRadius = 0.25f; + float haloBlur = 1.0f; float size = 12.0f; float rotate = 0.0f; bool alwaysVisible = false; diff --git a/src/renderer/painter_text.cpp b/src/renderer/painter_text.cpp index a17f162e9..5c7adcff8 100644 --- a/src/renderer/painter_text.cpp +++ b/src/renderer/painter_text.cpp @@ -41,8 +41,6 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons textShader->setTextureSize({{static_cast(map.getGlyphAtlas().width), static_cast(map.getGlyphAtlas().height)}}); - textShader->setGamma(2.5f / fontSize / map.getState().getPixelRatio()); - // Convert the -pi..pi to an int8 range. float angle = round((map.getState().getAngle() + rotate) / M_PI * 128); @@ -98,15 +96,19 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons // We're drawing in the translucent pass which is bottom-to-top, so we need // to draw the halo first. if (properties.halo[3] > 0.0f) { + textShader->setGamma(properties.haloBlur * 2.4f / fontSize / map.getState().getPixelRatio()); textShader->setColor(properties.halo); textShader->setBuffer(properties.haloRadius); glDepthRange(strata, 1.0f); bucket.drawGlyphs(*textShader); } - // Then, we draw the text over the halo - textShader->setColor(properties.color); - textShader->setBuffer((256.0f - 64.0f) / 256.0f); - glDepthRange(strata + strata_epsilon, 1.0f); - bucket.drawGlyphs(*textShader); + if (properties.color[3] > 0.0f) { + // Then, we draw the text over the halo + textShader->setGamma(2.4f / fontSize / map.getState().getPixelRatio()); + textShader->setColor(properties.color); + textShader->setBuffer((256.0f - 64.0f) / 256.0f); + glDepthRange(strata + strata_epsilon, 1.0f); + bucket.drawGlyphs(*textShader); + } } diff --git a/src/style/style.cpp b/src/style/style.cpp index ecb86108e..952e5fc6d 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -102,6 +102,7 @@ void Style::cascade(float z) { text.size = layer.size.evaluate(z); text.halo = layer.halo; text.haloRadius = layer.haloRadius.evaluate(z); + text.haloBlur = layer.haloBlur.evaluate(z); text.rotate = layer.rotate.evaluate(z); text.alwaysVisible = layer.alwaysVisible.evaluate(z); text.opacity = layer.opacity.evaluate(z); diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 83c408dd3..4302473ec 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -571,6 +571,10 @@ TextClass StyleParser::parseTextClass(JSVal value) { klass.haloRadius = parseFunction(value["strokeWidth"]); } + if (value.HasMember("strokeBlur")) { + klass.haloBlur = parseFunction(value["strokeBlur"]); + } + if (value.HasMember("size")) { klass.size = parseFunction(value["size"]); }