- Home /
The question is answered, right answer was accepted
How is SinTime measured in shaders?
Trying to use SinTime, doesnt seem to work how I expected. What kind of value is SinTime giving? is it a -1 to 1 value? or a continuous growing int?
Answer by Bunny83 · May 07, 2016 at 04:40 AM
Well, just looking at the name i would guess it's between -1 and 1. By taking a quick look into the documentation we can see that sintime is actually a float4 and each component has a different value.
So:
_SinTime.x == Sin(t/8)
_SinTime.y == Sin(t/4)
_SinTime.z == Sin(t/2)
_SinTime.w == Sin(t)
Seen docs, but when I try to clamp to half of sintime, to sintime, it seems to not smoothly transition from the half.
I'm trying to make it it less strong of a sin wave basically. But it is not turning out smooth.
What does "clamp to half of sintime" mean? Clamping always sounds like it will not end up smooth ^^. And what do you mean by "less strong"? If you just want to lower the amplitude, just multiply it by a value smaller than 1.0.
_SinTime.x*0.2 --> [-0.2, 0.2]
If you want a slower frequency you have to provide that manually. Unity only provides those 4 predefined values.
You can calculate the sine directly in the shader, but it's actually a waste of GPU power since you would recalculate it for every vertex / fragment. It's better to provide your custom value with a global shader parameter and set / update the value in Update in a script
Well, I guess I phrased that wrong, I am trying to up the base line value of sine, but I guess I could juts + 0.1 or whatever. But what I'm trying to do is more like force SinTime, to be the same as Time, or a bit slower. And I assume Time is like SinTime to amplitude of 1 constantly. But it doesnt seem to do Sin anymore when clamped, just outputs the $$anonymous$$ of clamp.
like
clamp(_SinTime.w,_Time.x, _Time.y)
Justed edited the xyzw, so they match up as
clamp(_SinTime.w(time),_Time.x(time/20), _Time.y(time))
Follow this Question
Related Questions
How can i create a time bubble effect ? 0 Answers
How to force the compilation of a shader in Unity? 5 Answers
Shader time related questions 1 Answer
Built-in ShaderLab "_Time.y" and "Time.time" are not equal? 5 Answers
Change input values based on Time 0 Answers