I have several shaders that use the Time node to animate certain UI elements for my mobile game. In certain cases (which I am unable to reproduce), the shaders will be stuck on a specific time and not animate.
For example, a shine shader might be stuck mid-shine.
Some important things to note:
Time.timeScale
is 1 - all my tweens using scaled delta time are working correctly- When this happens all shaders using the time node in the active scene will "freeze in time"
- This only reproduces on actual Android devices (iOS untested)
- All parameters affecting time in said shaders are positive, valid numbers
- There are no errors or warnings
- When I transition from my main menu scene to the game scene, time based shaders will work correctly - when I come back to the main scene, it will reproduce again (obviously it's something specifically there)
- Running on Unity 2019.4.11f1 with URP & Shader Graph 7.5.1, but it did reproduce in older versions of Unity/URP as well
Sample shader - The preview actually looks exactly like the issue as it will appear in game when frozen:
For any lost souls who stumble upon this issue (although I doubt it's by design as it seems like a bug).
The problem is that time isn't updated in shaders in scenes without a camera. The camera doesn't have to render anything; it just needs to exist.
My main menu is pure UI elements and had no camera; adding a camera to the scene fixed the issue.
It is important to note that this behavior only happens once you build to an Android device; not sure if it reproduces on other platforms.