distance.fragment.glsl 354 B

123456789101112131415
  1. #ifdef GL_ES
  2. precision mediump float;
  3. #endif
  4. uniform sampler2D u_texture;
  5. uniform float scale;
  6. varying vec4 v_color;
  7. varying vec2 v_texCoord;
  8. void main() {
  9. float distance = texture2D(u_texture, v_texCoord).a;
  10. float alpha = smoothstep(0.5 - 0.08 / scale, 0.5 + 0.08 / scale, distance) * v_color.a;
  11. gl_FragColor = vec4(v_color.rgb, alpha);
  12. }