BlinkShader.vsh
attribute vec4 a_position;
attribute vec2 a_texcoord;
attribute vec4 a_color;
#ifdef GL ES
varying mediump vec2 v_texcoord;
varying mediump vec4 v_fragmentColor;
#else
varying vec2 v_texCoord;
varying vec4 v_fragmentColor;
#endif
uniform float u_radian;
void main()
{
gl_Position CC_PMatrix a_position;
v_texCoord a_texCoord;
v_fragmentColor a_color;
}
BlinkShader.fsh
#ifdef GL_ES
varying mediump vec2 v_texCoord;
varying mediump vec4 v_fragmentColor;
#else
varying vec2 v_texCoord;
varying vec4 v_fragmentColor;
#endif
uniform float u_radian;
//uniform float speed;
//uniform vec4 color;IN
void main()
{
vec4 color v_fragmentColor texture2D(CC_Texturee,v_texCoord);
gl_FragColor =vec4((color.rgb abs(sin(u_radian))*0.4)*color.a,color.a);
}
local shader = cc.GLProgram.createWithFIlenames("BlinkShader.vsh","BlinkShader.fsh");
image.setShaderProgram(shader);
cc.ShaderCache.getInstance().addProgram(shader,"BlinsShader");
image.getGLProgramState().setUniformFloat("u_radian",0);
local radian = 0;
update:function(dt){
radian = radian + dt;
image.getGLProgramState().setUniformFloat("u_radian",radian);
}
|