add strokeBlur property (default 1.0, larger values blur more) to achieve a gradient effect

fixes #194
This commit is contained in:
Konstantin Käfer
2014-05-14 15:27:49 +02:00
parent 2d938f2ec2
commit 790b6cbdb3
4 changed files with 16 additions and 7 deletions

View File

@@ -41,8 +41,6 @@ void Painter::renderText(TextBucket& bucket, const std::string& layer_name, cons
textShader->setTextureSize({{static_cast<float>(map.getGlyphAtlas().width),
static_cast<float>(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);
}
}