Skip to content

Commit 20c4aac

Browse files
committed
Fixed sdf for emojis
1 parent 645bc2b commit 20c4aac

File tree

2 files changed

+4
-11
lines changed
  • common/src/main
    • kotlin/com/lambda/graphics/renderer/gui/font/core
    • resources/assets/lambda/shaders/fragment/font

2 files changed

+4
-11
lines changed

common/src/main/kotlin/com/lambda/graphics/renderer/gui/font/core/LambdaAtlas.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ object LambdaAtlas : Loadable {
136136
val uv1 = Vec2d(x, y) * texelSize
137137
val uv2 = Vec2d(x, y).plus(size) * texelSize
138138

139-
constructed[name] = GlyphInfo(size, -uv1, -uv2)
139+
val normalized = 128.0 / size.y
140+
constructed[name] = GlyphInfo(size * normalized, -uv1, -uv2)
140141

141142
x += emoji.width + 2
142143
}

common/src/main/resources/assets/lambda/shaders/fragment/font/font.frag

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,12 @@ float sdf(float channel) {
1414
return 1.0 - smoothstep(u_SDFMin, u_SDFMax, 1.0 - channel);
1515
}
1616

17-
vec4 sdf(vec4 texture) {
18-
return vec4(
19-
sdf(texture.r),
20-
sdf(texture.g),
21-
sdf(texture.b),
22-
sdf(texture.a)
23-
);
24-
}
25-
2617
void main() {
2718
bool isEmoji = v_TexCoord.x < 0.0;
2819

2920
if (isEmoji) {
30-
color = sdf(texture(u_EmojiTexture, -v_TexCoord)) * v_Color;
21+
vec4 c = texture(u_EmojiTexture, -v_TexCoord);
22+
color = vec4(c.rgb, sdf(c.a)) * v_Color;
3123
return;
3224
}
3325

0 commit comments

Comments
 (0)