varying vec2 v_texCoord;
//uniform float u_CurrentTime;
uniform float u_ChangeTime;
uniform float u_frameInterval;
uniform int u_CurrentFrame;
uniform int CC_TotalFrame;
uniform sampler2D u_texture;

void main()
{
    vec4 c = texture2D(u_texture, v_texCoord);
    int pastFrame = CC_TotalFrame - u_CurrentFrame;
    if(pastFrame < 0){
        pastFrame = 0;
    }
    float pastFrameF = float(pastFrame);
    float pastSec = pastFrameF * u_frameInterval;
    float per = pastSec / u_ChangeTime;
//    float per = (CC_Time[1] - u_CurrentTime) / u_ChangeTime;
    vec3 white = vec3(1.0, 1.0, 1.0) * per * c.a;
    if (white.r > 1.0) {
        white.r = 1.0;
    }
    if (white.g > 1.0) {
        white.g = 1.0;
    }
    if (white.b > 1.0) {
        white.b = 1.0;
    }
    vec3 whiteIn = vec3(1.0 - white.r, 1.0 - white.g, 1.0 - white.b);
    if (c.a > 0.0) {
        gl_FragColor = vec4(c.rgb + whiteIn, c.a);
    }else{
        gl_FragColor = c;
    }
}
