2012-09-01 20:43:46 +02:00
|
|
|
#ifdef GL_ES
|
2014-08-09 23:43:18 +02:00
|
|
|
#extension GL_OES_standard_derivatives : enable
|
2012-09-01 20:43:46 +02:00
|
|
|
precision mediump float;
|
|
|
|
precision mediump int;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Input :
|
|
|
|
uniform sampler2D EW_texID;
|
2012-09-07 16:32:54 +02:00
|
|
|
uniform float EW_SoftEdgeMin;
|
|
|
|
uniform float EW_SoftEdgeMax;
|
|
|
|
uniform int EW_SoftEdge;
|
2012-09-01 20:43:46 +02:00
|
|
|
|
|
|
|
varying vec2 f_texcoord;
|
|
|
|
varying vec4 f_color;
|
2014-01-17 22:49:11 +01:00
|
|
|
varying float f_glyphLevel;
|
2012-09-01 20:43:46 +02:00
|
|
|
|
2014-01-08 22:15:01 +01:00
|
|
|
const float glyph_center = 0.50;
|
|
|
|
const float outline_center = 0.55;
|
2014-01-14 23:56:17 +01:00
|
|
|
const float glow_center = 1.55;
|
2014-01-08 22:15:01 +01:00
|
|
|
|
2014-01-14 23:56:17 +01:00
|
|
|
vec3 glyph_color = vec3(0.0,0.0,0.0);
|
2014-01-14 21:50:21 +01:00
|
|
|
vec3 outline_color = vec3(0.0,0.0,0.0);
|
2014-01-14 23:56:17 +01:00
|
|
|
vec3 glow_color = vec3(0.0,0.0,0.0);
|
2014-01-14 21:50:21 +01:00
|
|
|
|
2012-09-01 20:43:46 +02:00
|
|
|
void main(void) {
|
2014-01-08 22:15:01 +01:00
|
|
|
vec4 color = texture2D(EW_texID, f_texcoord );
|
|
|
|
float dist = color.r;
|
|
|
|
float width = fwidth(dist);
|
2014-01-17 22:49:11 +01:00
|
|
|
float alpha = smoothstep(f_glyphLevel-width, f_glyphLevel+width, dist);
|
2014-01-08 22:15:01 +01:00
|
|
|
|
|
|
|
// Smooth
|
2014-01-14 21:50:21 +01:00
|
|
|
gl_FragColor = vec4(f_color[0], f_color[1], f_color[2], f_color[3]*alpha);
|
2014-01-08 22:15:01 +01:00
|
|
|
|
|
|
|
// Outline
|
|
|
|
/*
|
|
|
|
float mu = smoothstep(outline_center-width, outline_center+width, dist);
|
|
|
|
vec3 rgb = mix(outline_color, glyph_color, mu);
|
|
|
|
gl_FragColor = vec4(rgb, max(alpha,mu));
|
|
|
|
*/
|
|
|
|
// Glow
|
2014-01-08 21:15:01 +01:00
|
|
|
/*
|
2014-01-08 22:15:01 +01:00
|
|
|
vec3 rgb = mix(glow_color, glyph_color, alpha);
|
|
|
|
float mu = smoothstep(glyph_center, glow_center, sqrt(dist));
|
|
|
|
gl_FragColor = vec4(rgb, max(alpha,mu));
|
2012-09-06 18:42:06 +02:00
|
|
|
*/
|
2014-01-08 22:15:01 +01:00
|
|
|
|
|
|
|
// Glow + outline
|
2014-01-08 21:15:01 +01:00
|
|
|
/*
|
2014-01-08 22:15:01 +01:00
|
|
|
vec3 rgb = mix(glow_color, glyph_color, alpha);
|
|
|
|
float mu = smoothstep(glyph_center, glow_center, sqrt(dist));
|
|
|
|
color = vec4(rgb, max(alpha,mu));
|
|
|
|
float beta = smoothstep(outline_center-width, outline_center+width, dist);
|
|
|
|
rgb = mix(outline_color, color.rgb, beta);
|
|
|
|
gl_FragColor = vec4(rgb, max(color.a,beta));
|
2014-01-08 21:15:01 +01:00
|
|
|
*/
|
2012-09-01 20:43:46 +02:00
|
|
|
}
|