docs/android/dokka/filament-android/com.google.android.filament/-renderer/get-material-time.md
//filament-android/com.google.android.filament/Renderer/getMaterialTime
[main]
open fun getMaterialTime(): Double
Returns a timestamp (in seconds) for the last call to beginFrame. This value is constant for all views rendered during a frame. The epoch is set with setMaterialTimeEpoch.
In materials, this value can be queried using vec4 getUserTime(). The value returned is a highp vec4 encoded as follows:
time.x = (float)Renderer.getMaterialTime();
time.y = Renderer.getMaterialTime() - time.x;
It follows that the following invariants are true: ```kotlin (double)time.x + (double)time.y == Renderer.getMaterialTime() time.x == (float)Renderer.getMaterialTime()
This "float-float" encoding allows the shader code to perform high precision (i.e. double) time calculations when needed despite the lack of double precision in the shader (e.g. using Dekker's algorithms), e.g.: To compute `(double)time * vertex` in the material, use the following construct: ```kotlin
vec3 result = time.x * vertex + time.y * vertex;
Most of the time, high precision computations are not required, but be aware that the precision of time.x rapidly diminishes as time passes:
In other words, it is only possible to get microsecond accuracy for about 16s or millisecond accuracy for just under 5h. This problem can be mitigated by calling setMaterialTimeEpoch, or using high precision time as described above.
the time in seconds since setMaterialTimeEpoch was last called
| setMaterialTimeEpoch |