diff options
author | Joe Wilm <joe@jwilm.com> | 2016-05-20 21:36:28 -0700 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2016-05-20 21:36:28 -0700 |
commit | c70acbac0b721ea2f1b1442898c22aee0f360ef2 (patch) | |
tree | a78722cbabb59c59e7dacc02a4c4d05405839dea /res | |
parent | e794bc11b962adef4d6fbbaeb85344cb138376da (diff) | |
download | alacritty-c70acbac0b721ea2f1b1442898c22aee0f360ef2.tar.gz alacritty-c70acbac0b721ea2f1b1442898c22aee0f360ef2.zip |
Correct sub-pixel font rendering with OpenGL
Uses the GL_ARB_blend_func_extended to get single-pass, per-channel
alpha blending. gl_generator is now used instead of gl to enable the
extension.
The background color is removed since that presumably needs to run in a
separate pass.
Diffstat (limited to 'res')
-rw-r--r-- | res/text.f.glsl | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/res/text.f.glsl b/res/text.f.glsl index 7e80a11c..3389fd7e 100644 --- a/res/text.f.glsl +++ b/res/text.f.glsl @@ -1,30 +1,14 @@ #version 330 core in vec2 TexCoords; +layout(location = 0, index = 0) out vec4 color; +layout(location = 0, index = 1) out vec4 alphaMask; + uniform sampler2D mask; uniform vec3 textColor; -uniform vec3 bgColor; - -// SRC = SRC_ALPHA; DST = 1 - SRC_ALPHA -void MyBlend(in vec3 srcValue, - in vec3 dstValue, - in vec3 srcAlpha, - out vec3 blended) -{ - vec3 dstAlpha = vec3(1.0, 1.0, 1.0) - srcAlpha; - vec3 preBlended = (srcValue * srcAlpha + dstValue * dstAlpha); - - blended = vec3(min(1.0, preBlended.x), - min(1.0, preBlended.y), - min(1.0, preBlended.z)); -} void main() { - // vec4 red = vec4(sampled.rgb, sampled.r * sampled.g * sampled.b); - // vec4 sampled = vec4(1.0, 1.0, 1.0, texture(mask, TexCoords)); - vec3 blended = vec3(1.0, 1.0, 1.0); - MyBlend(textColor, bgColor, texture(mask, TexCoords).rgb, blended); - - gl_FragColor = vec4(blended, 1.0); + alphaMask = vec4(texture(mask, TexCoords).rgb, 1.); + color = vec4(textColor, 1.); } |