#extension GL_OES_standard_derivatives : enable
precision mediump float;
varying vec4 f_Color;
varying vec3 f_BC;
varying float f_FillType;
float edgeFactor(){
vec3 d = fwidth(f_BC);
vec3 a3 = smoothstep(vec3(0.0), d*1.5, f_BC);
return min(min(a3.x, a3.y), a3.z);
}
void main(){
if(gl_FrontFacing){
gl_FragColor = vec4(0.0, 0.0, 0.0, (1.0-edgeFactor())*0.95);
} else {
gl_FragColor = vec4(0.0, 0.0, 0.0, (1.0-edgeFactor())*0.7);
}
}
function InitGL(canvas) {
var gl = WebGLUtils.setupWebGL(canvas,'OES_standard_derivatives');
if (!gl) {
alert ("WebGL isn't available");
}
// required to turn on fwidth and such.
gl.getExtension('OES_standard_derivatives');
return gl;
}
this.gl.enable(this.gl.BLEND); this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
this.direction = this.gl.CCW; this.gl.frontFace(this.direction);
this.gl.enable(this.gl.CULL_FACE); this.gl.cullFace(this.gl.BACK)