大家好
在我们的项目中 为了节省资源 所以会用一张灰图 再通过setColor(ccRed)设置颜色
我们需要点击图片高亮,我通过shader来实现高亮,代码如下:
#ifdef GL_ES \n
precision mediump float; \n
#endif \n
\n
uniform sampler2D u_texture; \n
varying vec2 v_texCoord; \n
varying vec4 v_fragmentColor; \n
\n
void main(void) \n
{ \n
// Convert to greyscale using NTSC weightings \n
vec4 col = texture2D(u_texture, v_texCoord); \n
float plus = 0.2 * col.a; \n
float r = col.r + plus > 1.0 ? 1.0 : col.r + plus; \n
float g = col.g + plus > 1.0 ? 1.0 : col.g + plus; \n
float b = col.b + plus > 1.0 ? 1.0 : col.b + plus; \n
gl_FragColor = vec4(r, g, b, col.a); \n
} \n
";
目前可以实现点击普通图片会高亮效果,但如果点击通过setColor的图片,会变成灰图高亮 不是红色高亮
大家有遇到类似问题或者有解决办法吗??