Shader Time Uniform - clock_gettime being truncated
问题 Take this function getting time as a double using clock_gettime: // return current time in milliseconds static double time_get_ms(void) { struct timespec res; #ifdef ANDROID clock_gettime(CLOCK_REALTIME_HR, &res); #else clock_gettime(CLOCK_REALTIME, &res); #endif return (double)(1000.0*res.tv_sec + res.tv_nsec/1e6); } Sending it to a shader requires conversion to float. The mantissa is being overflowed and is truncated on the way to the shader. Example: As a double = 1330579093642.441895 As a