ccShader_Label_df.frag 787 B

1234567891011121314151617181920212223242526
  1. const char* ccLabelDistanceFieldNormal_frag = R"(
  2. #ifdef GL_ES
  3. precision lowp float;
  4. #endif
  5. varying vec4 v_fragmentColor;
  6. varying vec2 v_texCoord;
  7. uniform vec4 u_textColor;
  8. void main()
  9. {
  10. vec4 color = texture2D(CC_Texture0, v_texCoord);
  11. //the texture use dual channel 16-bit output for distance_map
  12. //float dist = color.b+color.g/256.0;
  13. // the texture use single channel 8-bit output for distance_map
  14. float dist = color.a;
  15. //TODO: Implementation 'fwidth' for glsl 1.0
  16. //float width = fwidth(dist);
  17. //assign width for constant will lead to a little bit fuzzy,it's temporary measure.
  18. float width = 0.04;
  19. float alpha = smoothstep(0.5-width, 0.5+width, dist) * u_textColor.a;
  20. gl_FragColor = v_fragmentColor * vec4(u_textColor.rgb,alpha);
  21. }
  22. )";