diff --git a/src/main/java/io/github/hydos/ginger/font/MetaFile.java b/src/main/java/io/github/hydos/ginger/font/MetaFile.java index 50cb41a..adb6fdb 100644 --- a/src/main/java/io/github/hydos/ginger/font/MetaFile.java +++ b/src/main/java/io/github/hydos/ginger/font/MetaFile.java @@ -20,7 +20,7 @@ public class MetaFile { private static final int PAD_BOTTOM = 2; private static final int PAD_RIGHT = 3; - private static final int DESIRED_PADDING = 3; + private static final int DESIRED_PADDING = 8; private static final String SPLITTER = " "; private static final String NUMBER_SEPARATOR = ","; diff --git a/src/main/resources/shaders/fontFragmentShader.glsl b/src/main/resources/shaders/fontFragmentShader.glsl index 100b0fe..295a947 100644 --- a/src/main/resources/shaders/fontFragmentShader.glsl +++ b/src/main/resources/shaders/fontFragmentShader.glsl @@ -7,8 +7,27 @@ out vec4 out_colour; uniform vec3 colour; uniform sampler2D fontAtlas; +const float width = 0.5; +const float edge = 0.1; + +uniform float borderWidth = 0.0; +uniform float borderEdge = 0.1; + +uniform vec2 offset = vec2(0.0, 0.0); + +uniform vec3 outlineColour = vec3(1.0,0.0,0.0); + void main(void){ - out_colour = vec4(colour, texture(fontAtlas, pass_textureCoords).a); + float distance = 1.0 - texture(fontAtlas, pass_textureCoords).a; + float alpha = 1.0 - smoothstep(width, width + edge, distance); + + float distance2 = 1.0 - texture(fontAtlas, pass_textureCoords + offset).a; + float outlineAlpha = 1.0 - smoothstep(borderWidth, borderWidth + borderEdge, distance2); + + float overallAlpha = alpha + (1.0 - alpha) * outlineAlpha; + vec3 overallColour = mix(outlineColour, colour, alpha / overallAlpha); + + out_colour = vec4(overallColour, overallAlpha); } diff --git a/target/classes/io/github/hydos/ginger/font/MetaFile.class b/target/classes/io/github/hydos/ginger/font/MetaFile.class index 98d868f..3aebae0 100644 Binary files a/target/classes/io/github/hydos/ginger/font/MetaFile.class and b/target/classes/io/github/hydos/ginger/font/MetaFile.class differ diff --git a/target/classes/io/github/hydos/ginger/font/TextMeshCreator.class b/target/classes/io/github/hydos/ginger/font/TextMeshCreator.class index 43c7e32..1e6ca04 100644 Binary files a/target/classes/io/github/hydos/ginger/font/TextMeshCreator.class and b/target/classes/io/github/hydos/ginger/font/TextMeshCreator.class differ diff --git a/target/classes/shaders/fontFragmentShader.glsl b/target/classes/shaders/fontFragmentShader.glsl index 100b0fe..295a947 100644 --- a/target/classes/shaders/fontFragmentShader.glsl +++ b/target/classes/shaders/fontFragmentShader.glsl @@ -7,8 +7,27 @@ out vec4 out_colour; uniform vec3 colour; uniform sampler2D fontAtlas; +const float width = 0.5; +const float edge = 0.1; + +uniform float borderWidth = 0.0; +uniform float borderEdge = 0.1; + +uniform vec2 offset = vec2(0.0, 0.0); + +uniform vec3 outlineColour = vec3(1.0,0.0,0.0); + void main(void){ - out_colour = vec4(colour, texture(fontAtlas, pass_textureCoords).a); + float distance = 1.0 - texture(fontAtlas, pass_textureCoords).a; + float alpha = 1.0 - smoothstep(width, width + edge, distance); + + float distance2 = 1.0 - texture(fontAtlas, pass_textureCoords + offset).a; + float outlineAlpha = 1.0 - smoothstep(borderWidth, borderWidth + borderEdge, distance2); + + float overallAlpha = alpha + (1.0 - alpha) * outlineAlpha; + vec3 overallColour = mix(outlineColour, colour, alpha / overallAlpha); + + out_colour = vec4(overallColour, overallAlpha); } diff --git a/target/ginger-NIGHTLY.jar b/target/ginger-NIGHTLY.jar deleted file mode 100644 index efc61a3..0000000 Binary files a/target/ginger-NIGHTLY.jar and /dev/null differ