mutoo
3/19/2014 - 2:25 PM

gray.fsh

attribute vec4 a_position;
attribute vec2 a_texCoord;
attribute vec4 a_color;
varying lowp vec4 v_fragmentColor;
varying mediump vec2 v_texCoord;
void main()
{
    gl_Position = (CC_PMatrix * CC_MVMatrix) * a_position;
    v_fragmentColor = a_color;
    v_texCoord = a_texCoord;
}
precision lowp float;
varying vec4 v_fragmentColor;
varying vec2 v_texCoord;
uniform sampler2D CC_Texture0;
void main()
{
    vec4 tex = texture2D(CC_Texture0, v_texCoord);
    float gray = dot(tex.rgb, vec3(0.299, 0.587, 0.114));
    gl_FragColor = v_fragmentColor * vec4(gray, gray, gray, tex[3]);
}