What is CC_Time in cocos2dx?

I was following this tutorial to understand using custom shaders : http://www.cocos2d-x.org/wiki/User_Tutorial-Realistic_looking_animated_real-time_clouds

I understand that CC_Time is Cocos2d-x built-in uniform vec4-object that holds different versions of time in it’s components. Can someone please explain or point me to a resource so that I can understand what are its different components. Thanks.

If you dive deep into the source you’ll find this. Each element in the float array is essentially a ready to use pre-calculated fraction or multiple of the approx. (see comment) current time in seconds.

// This doesn't give the most accurate global time value.
// Cocos2D doesn't store a high precision time value, so this will have to do.
// Getting Mach time per frame per shader using time could be extremely expensive.
float time = _director->getTotalFrames() * _director->getAnimationInterval();

setUniformLocationWith4f(_builtInUniforms[GLProgram::UNIFORM_TIME], time/10.0, time, time*2, time*4);
setUniformLocationWith4f(_builtInUniforms[GLProgram::UNIFORM_SIN_TIME], time/8.0, time/4.0, time/2.0, sinf(time));
setUniformLocationWith4f(_builtInUniforms[GLProgram::UNIFORM_COS_TIME], time/8.0, time/4.0, time/2.0, cosf(time));
1 Like

Thanks for the prompt reply @stevetranby