- Home /
Shader time related questions
I'm creating time based effects in my shader. I want to understand how "time" works within a shader. Here are a few of the questions that I'm unable to find an answer:
I'm creating a sin based "blinking" effect with time - how can I match it to seconds (so that I'll get a blink per second?
Is the shader time related to the speed of the machine? If it runs on slower machines - will it get de-synched (compared to a faster machine)
Answer by aldonaletto · May 11, 2013 at 03:18 PM
Unity provides some time related global variables at shader level: if you want the current time, for instance, read _Time.y; for the current Time.deltaTime, read unity_DeltaTime.x. The time related variables are the following:
float4 _Time : _Time.x = t/20, _Time.y = t, _Time.x = t*2, t*3), use to animate things inside the shaders
float4 _SinTime : Sine of time: (t/8, t/4, t/2, t)
float4 _CosTime : Cosine of time: (t/8, t/4, t/2, t)
float4 unity_DeltaTime : Delta time: (dt, 1/dt, smoothDt, 1/smoothDt)
How about synchronisation? When I use _Time to create a sine (or directly use _SinTime) does it slow down when the player's computer is slower?
Your answer
Follow this Question
Related Questions
UnityObjectToClipPos is inverted? 0 Answers
Flat Shading / No Vertex Interpolation 2 Answers
Access to svPosition in fragment shader 1 Answer
Shaders problems after moving to URP 0 Answers
Shader works differently on Android (OpenGL) and Editor (DX11) 0 Answers