在GLProgram::setUniformsForBuiltins函数中有下面代码:
if(_flags.usesTime) {
// 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, time/10.0, time, time*2, time*4);
setUniformLocationWith4f(_builtInUniforms, time/8.0, time/4.0, time/2.0, sinf(time));
setUniformLocationWith4f(_builtInUniforms, time/8.0, time/4.0, time/2.0, cosf(time));
}
我的疑问是:
(1)time不会溢出吗?
(2)time是float类型,作为uniform传到shader中,cocos2dx里float都是用的mediump精度,那么把float赋给mediump float不会溢出吗?
在自定义shader中使用了CC_Time,运行一段时间后画面不正常了,认为是这地方有问题造成的。