Make glyphs transparent.
Avoids cutting off the bottom of the "g" in the text demo.
This commit is contained in:
parent
72d9ad7de0
commit
83cfb1d9d5
|
@ -500,7 +500,7 @@ export class ECAAMonochromeStrategy extends ECAAStrategy {
|
|||
}
|
||||
|
||||
protected clearForResolve(view: MonochromePathfinderView) {
|
||||
view.gl.clearColor(1.0, 1.0, 1.0, 1.0);
|
||||
view.gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
||||
view.gl.clear(view.gl.COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ export default class SSAAStrategy extends AntialiasingStrategy {
|
|||
}
|
||||
|
||||
attachMeshes(view: PathfinderDemoView) {}
|
||||
|
||||
|
||||
setFramebufferSize(view: PathfinderDemoView) {
|
||||
this.destFramebufferSize = glmatrix.vec2.clone(view.destAllocatedSize);
|
||||
|
||||
|
@ -81,6 +81,7 @@ export default class SSAAStrategy extends AntialiasingStrategy {
|
|||
view.gl.bindFramebuffer(view.gl.FRAMEBUFFER, view.destFramebuffer);
|
||||
view.gl.viewport(0, 0, view.destAllocatedSize[0], view.destAllocatedSize[1]);
|
||||
view.gl.disable(view.gl.DEPTH_TEST);
|
||||
view.gl.disable(view.gl.BLEND);
|
||||
|
||||
// Set up the blit program VAO.
|
||||
let resolveProgram;
|
||||
|
|
|
@ -496,7 +496,8 @@ class TextDemoView extends MonochromePathfinderView {
|
|||
this.gl.disable(this.gl.DEPTH_TEST);
|
||||
this.gl.disable(this.gl.SCISSOR_TEST);
|
||||
this.gl.blendEquation(this.gl.FUNC_ADD);
|
||||
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
|
||||
this.gl.blendFuncSeparate(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA,
|
||||
this.gl.ONE, this.gl.ONE);
|
||||
this.gl.enable(this.gl.BLEND);
|
||||
|
||||
// Clear.
|
||||
|
@ -544,7 +545,7 @@ class TextDemoView extends MonochromePathfinderView {
|
|||
this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
readonly bgColor: glmatrix.vec4 = glmatrix.vec4.fromValues(1.0, 1.0, 1.0, 1.0);
|
||||
readonly bgColor: glmatrix.vec4 = glmatrix.vec4.fromValues(1.0, 1.0, 1.0, 0.0);
|
||||
readonly fgColor: glmatrix.vec4 = glmatrix.vec4.fromValues(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
get destFramebuffer(): WebGLFramebuffer {
|
||||
|
|
|
@ -381,7 +381,8 @@ export abstract class PathfinderDemoView extends PathfinderView {
|
|||
this.gl.depthMask(false);
|
||||
this.gl.enable(this.gl.BLEND);
|
||||
this.gl.blendEquation(this.gl.FUNC_ADD);
|
||||
this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
|
||||
this.gl.blendFuncSeparate(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA,
|
||||
this.gl.ONE, this.gl.ONE);
|
||||
|
||||
// Set up the direct curve VAO.
|
||||
const directCurveProgram = this.shaderPrograms[this.directCurveProgramName];
|
||||
|
|
|
@ -18,5 +18,5 @@ varying vec2 vTexCoord;
|
|||
|
||||
void main() {
|
||||
float alpha = clamp(texture2D(uAAAlpha, vTexCoord).r, 0.0, 1.0);
|
||||
gl_FragColor = mix(uBGColor, uFGColor, alpha);
|
||||
gl_FragColor = vec4(uFGColor.rgb, uFGColor.a * alpha);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,10 @@ void main() {
|
|||
sampleSource(2.0 * onePixel),
|
||||
sampleSource(3.0 * onePixel));
|
||||
|
||||
vec3 alpha = vec3(lcdFilter(shadeL.z, shadeL.y, shadeL.x, shade0, shadeR.x),
|
||||
lcdFilter(shadeL.y, shadeL.x, shade0, shadeR.x, shadeR.y),
|
||||
lcdFilter(shadeL.x, shade0, shadeR.x, shadeR.y, shadeR.z));
|
||||
vec3 shades = vec3(lcdFilter(shadeL.z, shadeL.y, shadeL.x, shade0, shadeR.x),
|
||||
lcdFilter(shadeL.y, shadeL.x, shade0, shadeR.x, shadeR.y),
|
||||
lcdFilter(shadeL.x, shade0, shadeR.x, shadeR.y, shadeR.z));
|
||||
|
||||
gl_FragColor = mix(uBGColor, uFGColor, vec4(alpha, 1.0));
|
||||
vec3 color = mix(uBGColor.rgb, uFGColor.rgb, shades);
|
||||
gl_FragColor = vec4(color, any(greaterThan(shades, vec3(0.0))) ? uFGColor.a : uBGColor.a);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ uniform ivec2 uSourceDimensions;
|
|||
varying vec2 vTexCoord;
|
||||
|
||||
float sampleSource(float deltaX) {
|
||||
return texture2D(uSource, vec2(vTexCoord.s + deltaX, vTexCoord.y)).r;
|
||||
return texture2D(uSource, vec2(vTexCoord.s + deltaX, vTexCoord.y)).a;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -30,8 +30,11 @@ void main() {
|
|||
sampleSource(2.0 * onePixel),
|
||||
sampleSource(3.0 * onePixel));
|
||||
|
||||
gl_FragColor = vec4(lcdFilter(shadeL.z, shadeL.y, shadeL.x, shade0, shadeR.x),
|
||||
lcdFilter(shadeL.y, shadeL.x, shade0, shadeR.x, shadeR.y),
|
||||
lcdFilter(shadeL.x, shade0, shadeR.x, shadeR.y, shadeR.z),
|
||||
1.0);
|
||||
vec3 color = vec3(lcdFilter(shadeL.z, shadeL.y, shadeL.x, shade0, shadeR.x),
|
||||
lcdFilter(shadeL.y, shadeL.x, shade0, shadeR.x, shadeR.y),
|
||||
lcdFilter(shadeL.x, shade0, shadeR.x, shadeR.y, shadeR.z));
|
||||
|
||||
// FIXME(pcwalton): This can be wrong in some cases. Need subpixel-aware compositing in the
|
||||
// text demo...
|
||||
gl_FragColor = vec4(vec3(1.0) - color, any(greaterThan(color, vec3(0.0))) ? 1.0 : 0.0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue