
CCEffect %{
  techniques:
  - passes:
    - vert: vs
      frag: fs
      blendState:
        targets:
        - blend: true
      rasterizerState:
        cullMode: none
      properties:
        texture: { value: white }
                # 描边颜色
        outlineColor: { 
          value: [1.0, 0.0, 0.0, 1.0], 
          editor: {
            type: color,
            tooltip: "描边颜色",
          }
        }

        fntColor: { 
          value: [1.0, 0.0, 0.0, 1.0], 
          editor: {
            type: color,
            tooltip: "字体颜色",
          }
        }
}%

CCProgram vs %{

precision highp float;

#include <cc-global>

in vec3 a_position;

in mediump vec2 a_uv0;
out mediump vec2 v_uv0;

in vec4 a_color;
out vec4 v_color;

void main () {
  gl_Position = cc_matViewProj * vec4(a_position, 1);
  v_uv0 = a_uv0;
  v_color = a_color;
}

}%

CCProgram fs %{

precision highp float;

#include <texture>

uniform sampler2D texture;
in mediump vec2 v_uv0;
in vec4 v_color;

#if SHOW_OUT_LINE

  uniform Outline {
    // 描边颜色 
    vec4 outlineColor;
    // 字体颜色 
    vec4 fntColor;
  };

#endif

void main () {
  vec4 color = v_color;
  CCTexture(texture, v_uv0, color);
  //float gray = 0.2126*color.r + 0.7152*color.g + 0.0722*color.b;
  float temp = 1.0;


  if(color.a == 0.0)
  {

  }
  if(color.r ==1.0 && color.g ==1.0 && color.b == 1.0 )
  {
      color = vec4(fntColor.r*temp, fntColor.g*temp, fntColor.b*temp, color.a);
  }
  else if(color.r ==0.0 && color.g ==0.0 && color.b == 0.0)
  {
      color = vec4(outlineColor.r*temp, outlineColor.g*temp, outlineColor.b*temp, color.a);
  }
  else
  {
      temp = 1.0-(color.r /1.0 + color.g / 1.0 + color.b /1.0)/3.0;
      color = vec4(outlineColor.r*temp+(fntColor.r)*(1.0-temp), outlineColor.g*temp+(fntColor.g)*(1.0-temp), outlineColor.b*temp+(fntColor.b)*(1.0-temp), color.a);
      //color = outlineColor.r*temp + vec4(1.0,1.0,1.0,1.0)*(1.0-temp);
  }
  
  gl_FragColor =color;
}

}%