From cd00c4bbe89ea90e69e607d4b05b2f0a99bc7098 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Mon, 10 Dec 2018 17:15:32 -0800 Subject: [PATCH] Add getUserTimeModulo() to materials This calculates the modulo of the user time by a given value, using the high precision user time. This is useful for animations without having to worry about resetting the time. --- docs/Materials.md.html | 1 + shaders/src/common_getters.fs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/docs/Materials.md.html b/docs/Materials.md.html index 3a7cf52f72..d3c26a508a 100644 --- a/docs/Materials.md.html +++ b/docs/Materials.md.html @@ -1331,6 +1331,7 @@ type aliases: **getWorldCameraPosition()** | float3 | Position of the camera/eye in world space **getTime()** | float | Current time in seconds, may be reset regularly to avoid precision loss **getUserTime()** | float4 | Current time in seconds: `time`, `(double)time - time`, `0`, `0` +**getUserTimeMode(float m)** | float | Current time modulo m in seconds **getExposure()** | float | Photometric exposure of the camera **getEV100()** | float | [Exposure value at ISO 100](https://en.wikipedia.org/wiki/Exposure_value) of the camera diff --git a/shaders/src/common_getters.fs b/shaders/src/common_getters.fs index 428a36544e..964be0fc05 100644 --- a/shaders/src/common_getters.fs +++ b/shaders/src/common_getters.fs @@ -47,6 +47,10 @@ HIGHP vec4 getUserTime() { return frameUniforms.userTime; } +HIGHP float getUserTimeMod(float m) { + return mod(mod(frameUniforms.userTime.x, m) + mod(frameUniforms.userTime.y, m), m); +} + /** @public-api */ float getExposure() { return frameUniforms.exposure;