Font fixes
This commit is contained in:
@@ -38,12 +38,14 @@ float4 shadeVideo(ShaderContext context)
|
||||
float2 pixelTextUv = (1.0 / resolution) / safeTextSize;
|
||||
float2 sampleOffset = pixelTextUv * 0.38;
|
||||
float msdfDistance = sampleTitleTextMsdf(textUv);
|
||||
float fill = (
|
||||
float msdfFill = (
|
||||
coverage(msdfDistance, edge, aa) * 2.0 +
|
||||
coverage(sampleTitleTextMsdf(textUv + float2(sampleOffset.x, sampleOffset.y)), edge, aa) +
|
||||
coverage(sampleTitleTextMsdf(textUv + float2(-sampleOffset.x, sampleOffset.y)), edge, aa) +
|
||||
coverage(sampleTitleTextMsdf(textUv + float2(sampleOffset.x, -sampleOffset.y)), edge, aa) +
|
||||
coverage(sampleTitleTextMsdf(textUv + float2(-sampleOffset.x, -sampleOffset.y)), edge, aa)) / 6.0;
|
||||
float sdfFill = coverage(distance, edge, aa);
|
||||
float fill = min(msdfFill, sdfFill);
|
||||
float outlineEdge = edge - min(outlineWidth * 0.7, 0.48);
|
||||
float outline = coverage(distance, outlineEdge, aa);
|
||||
float outlineAlpha = saturate(outline - fill) * outlineColor.a;
|
||||
|
||||
@@ -83,6 +83,13 @@ void SampleAtlasPixel(const FontAtlasBuildOutput& atlas, double x, double y, uns
|
||||
}
|
||||
}
|
||||
|
||||
double GlyphAtlasCoordinate(double minBound, double maxBound, double uv)
|
||||
{
|
||||
if (maxBound - minBound <= 1.0)
|
||||
return (minBound + maxBound) * 0.5;
|
||||
return minBound + 0.5 + uv * ((maxBound - 0.5) - (minBound + 0.5));
|
||||
}
|
||||
|
||||
std::vector<unsigned char> ComposeTextTexture(
|
||||
const FontAtlasBuildOutput& atlas,
|
||||
const ShaderParameterDefinition& definition,
|
||||
@@ -135,8 +142,8 @@ std::vector<unsigned char> ComposeTextTexture(
|
||||
if (x < 0 || x >= static_cast<int>(width))
|
||||
continue;
|
||||
const double u = (static_cast<double>(x) + 0.5 - destLeft) / destWidth;
|
||||
const double atlasX = glyph.atlasLeft + u * (glyph.atlasRight - glyph.atlasLeft);
|
||||
const double atlasY = glyph.atlasTop + v * (glyph.atlasBottom - glyph.atlasTop);
|
||||
const double atlasX = GlyphAtlasCoordinate(glyph.atlasLeft, glyph.atlasRight, u);
|
||||
const double atlasY = GlyphAtlasCoordinate(glyph.atlasTop, glyph.atlasBottom, v);
|
||||
unsigned char sample[4] = {};
|
||||
SampleAtlasPixel(atlas, atlasX, atlasY, sample);
|
||||
unsigned char* destination = texturePixels.data() + (static_cast<std::size_t>(y) * width + static_cast<std::size_t>(x)) * 4u;
|
||||
|
||||
Reference in New Issue
Block a user