Actually I've migrated my FreeType font renderer from OpenGL 2.x to OpenGL 3.x support. Now rendering is supported on both platforms without any code change. So far so good. However I got a question to the GLSL fragment shader routine. Before I've migrated my source I've used this call for font sprite rasterization:
uniform sampler2D DiffuseMap;
varying vec4 vColor;
varying vec2 vTexCoord0;
gl_FragColor = vec4(vColor.rgb, texture2D(DiffuseMap, vTexCoord0).a);
With this snipped I got pin sharp results on font rendering also on blending: Pin sharp rendering sample But this snipped is not working on OpenGL 3.x. If I use this snipped I only got the sprite quads rasterized, filled with the vertex attribute color. The single font characters are not visible. By this reason I changed the snipped to:
vec4 vTexColor = texture2D(DiffuseMap, vTexCoord0.st);
gl_FragColor = (vTexColor.r, vTexColor.r, vTexColor.r, vTexColor.r)*vColor;
With this snipped the font rendering is working with both renderer. But on both renderer the font looks now unsharpen, especially on blending: Unsharpen rendering sample. For blending I use: GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD.
Could someone explain me what is the difference between both routines and why the first one doesn't work with OpenGL 3.x? Is it possible that alpha value mapping is not supported? Maybe knows someone how I could sharpen the rendering results if I have to use the second snipped?