X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=sdr%2Fdfont.p.glsl;fp=sdr%2Fdfont.p.glsl;h=0000000000000000000000000000000000000000;hp=0d4ef4db0c4eb53541bcdfa3c20c5ef1be880d9d;hb=47fdbdc2feec8d097d296fe019fbeb653c0b0efc;hpb=1c2b18e725db9e066d5dcb11123fc2019aec2ee7 diff --git a/sdr/dfont.p.glsl b/sdr/dfont.p.glsl deleted file mode 100644 index 0d4ef4d..0000000 --- a/sdr/dfont.p.glsl +++ /dev/null @@ -1,53 +0,0 @@ -uniform sampler2D tex; -uniform float smoothness; -uniform float height; - -varying vec2 local_pt; - -void gradcurves(float t, out float over, out float under); - -#define HALF_PI 1.570796326794897 - -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); - - // --- face gradients --- - float t = local_pt.y / height; - - float c_over, c_under; - float tlow = min(2.0 * t, 1.0); - gradcurves(tlow, c_over, c_under); - vec3 color_low = vec3(c_over, c_under, c_over); - - float thigh = max(2.0 * t - 1.0, 0.0); - gradcurves(thigh, c_over, c_under); - vec3 color_high = vec3(c_under, c_under, c_over); - - vec3 color = mix(color_low, color_high, step(0.5, t)); - - // --- bevel gradients --- - float bv_shade = mod(1.0 * dot(grad, normalize(vec2(0.1, 1.0))) * 0.5 + 0.5, 1.0); - - gradcurves(1.0 - bv_shade, c_over, c_under); - vec3 bv_col = vec3(c_under, c_under, c_over); - - gl_FragColor.rgb = mix(bv_col, color, outline); - gl_FragColor.a = glyph; -} - -void gradcurves(float t, out float over, out float under) -{ - over = cos(t * HALF_PI); - under = cos(t * HALF_PI + HALF_PI) + 1.0; -}