URP Shader Graph shaders time node doesn't work in certain situations

4k views Asked by At

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:

  1. Time.timeScale is 1 - all my tweens using scaled delta time are working correctly
  2. When this happens all shaders using the time node in the active scene will "freeze in time"
  3. This only reproduces on actual Android devices (iOS untested)
  4. All parameters affecting time in said shaders are positive, valid numbers
  5. There are no errors or warnings
  6. 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)
  7. 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: UI screen space shine shader

1

There are 1 answers

0
Ron On BEST ANSWER

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.