Adding Time Delay To Your Shader
Recently I've been playing around with Time within Amplify Shader Editor. I wanted to add a time delay within my shader without needing the assistance of an engineer for a Unity script to handle this. During my search I couldn't find much documentation or forum posts talking about this simple function, however stumbled upon a forum post that had an algorithm for how to handle a delay. I wanted to share this because I found myself frustrated and wishing there was a resource to help me learn how to do this simple task. So for all of you people who are wondering high level how this works, here you go:
To create a time delay you need to scale and clamp your time.
- Time/Total Time (Sum of Animation Time + Delay Time)
- Fract (Loops The Animation and Creates an Animation Ramp)
- Multiply By Total Time (Back To Normal Time Scale)
- Clamp The Animation Value Between 0 and Animation Time (Clamp Stops Animation At Loop Point)
Here is the node network preview:
Once you have this set up, you can easily convert this into an Amplify Shader Function so that you can reuse this function in other material shaders!