X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=vrfileman;a=blobdiff_plain;f=sdr%2Fdfont.p.glsl;h=cf60f274b6251abf7c176bef16b65dac13fb0e16;hp=890b4eff53415b9a2283bf60405941df3594ccd4;hb=d5b4970b66b1d6b4726dd360a452a0b5b3160f22;hpb=c380095b089e7ef6197b1d962f28b37a2cc3b5dd diff --git a/sdr/dfont.p.glsl b/sdr/dfont.p.glsl index 890b4ef..cf60f27 100644 --- a/sdr/dfont.p.glsl +++ b/sdr/dfont.p.glsl @@ -1,5 +1,12 @@ 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() { @@ -15,9 +22,32 @@ void main() 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); + // --- 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)); - gl_FragColor.rgb = mix(bevelcol, vec3(1.0), outline); + // --- bevel gradients --- + float bv_shade = mod(1.0 * dot(grad, normalize(vec2(1.0, 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; +}