forgot to add the new shaders
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sat, 6 Aug 2016 22:13:33 +0000 (01:13 +0300)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sat, 6 Aug 2016 22:13:33 +0000 (01:13 +0300)
sdr/dfont.p.glsl [new file with mode: 0644]
sdr/dfont.v.glsl [new file with mode: 0644]

diff --git a/sdr/dfont.p.glsl b/sdr/dfont.p.glsl
new file mode 100644 (file)
index 0000000..890b4ef
--- /dev/null
@@ -0,0 +1,23 @@
+uniform sampler2D tex;
+uniform float smoothness;
+
+void main()
+{
+       const vec2 pix_sz = vec2(1.0 / 512.0, 1.0 / 256.0);     // TODO: uniform
+
+       vec2 uv = gl_TexCoord[0].st;
+       float dist = texture2D(tex, uv).a;
+
+       float dfdu = texture2D(tex, uv + vec2(pix_sz.x, 0.0)).a - dist;
+       float dfdv = texture2D(tex, uv + vec2(0.0, pix_sz.y)).a - dist;
+       vec2 grad = normalize(vec2(dfdu, dfdv));
+
+       float glyph = smoothstep(0.47 - smoothness, 0.47 + smoothness, dist);
+       float outline = smoothstep(0.54 - smoothness, 0.54 + smoothness, dist);
+
+       float beveldot = max(dot(grad, normalize(vec2(1.0, 1.0))), 0.0);
+       vec3 bevelcol = mix(vec3(0.05, 0.1, 0.6), vec3(1.0, 0.2, 0.8), beveldot);
+
+       gl_FragColor.rgb = mix(bevelcol, vec3(1.0), outline);
+       gl_FragColor.a = glyph;
+}
diff --git a/sdr/dfont.v.glsl b/sdr/dfont.v.glsl
new file mode 100644 (file)
index 0000000..b446ef6
--- /dev/null
@@ -0,0 +1,5 @@
+void main()
+{
+       gl_Position = ftransform();
+       gl_TexCoord[0] = gl_MultiTexCoord0;
+}