- Home /
Shaders: Why is _Time stored in a vector4?
And what do they represent? I thought perhaps it just stored (UnityTime, 0, 0, 0), but this does not seem to be the case.
Why is this voted down? I find this to be a perfectly reasonable question.
+1.
Answer by Wolfram · Jun 13, 2012 at 05:32 PM
http://docs.unity3d.com/462/Documentation/Manual/SL-BuiltinValues.html
EDIT: link fixed; thanks @Usul
Thanks Wolfram. I actually took a look at that already, and couldn't make much sense of it. Am I to assume that 't' is the Time.time value, and that the vector just stores multiples of it? It seems a bit redundant... Or do I misunderstand?
float4 _Time : Time (t/20, t, t*2, t*3)
This means, _Time.y contains the regular time, _Time.x regular time /20, and so on. For whatever reason.
Answer by GeekyMonkey · Jan 01, 2017 at 07:16 PM
It's just a clever way of giving you 4 variations of the value, potentially saving you a multiply operation by re-using the pre-multiplied value for every pixel being rendered. There are 4 values available.
_Time.x = time / 20
_Time.y = time
_Time.z = time * 2
_Time.w = time * 3
I don't know why these specific values were chosen. Anyone have an idea?