|
- /* =========================================================================
- * Freetype GL - A C OpenGL Freetype engine
- * Platform: Any
- * WWW: http://code.google.com/p/freetype-gl/
- * -------------------------------------------------------------------------
- * Copyright 2011 Nicolas P. Rougier. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY NICOLAS P. ROUGIER ''AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
- * EVENT SHALL NICOLAS P. ROUGIER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and documentation are
- * those of the authors and should not be interpreted as representing official
- * policies, either expressed or implied, of Nicolas P. Rougier.
- * ========================================================================= */
- uniform sampler2D texture;
- vec3 glyph_color = vec3(1.0,1.0,1.0);
- const float glyph_center = 0.50;
- vec3 outline_color = vec3(0.0,0.0,0.0);
- const float outline_center = 0.55;
- vec3 glow_color = vec3(1.0,1.0,1.0);
- const float glow_center = 1.25;
- void main(void)
- {
- vec4 color = texture2D(texture, gl_TexCoord[0].st);
- float dist = color.r;
- float width = fwidth(dist);
- float alpha = smoothstep(glyph_center-width, glyph_center+width, dist);
-
- // Smooth
- // gl_FragColor = vec4(glyph_color, alpha);
-
- // 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
- //vec3 rgb = mix(glow_color, glyph_color, alpha);
- //float mu = smoothstep(glyph_center, glow_center, sqrt(dist));
- //gl_FragColor = vec4(rgb, max(alpha,mu));
-
- // Glow + outline
- 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));
-
- }
-
|