Reputation: 21
I'm trying to use Sine Time output from Time node but I want it to be faster.
If this is done in a Unity c#, I would try to something like this
totalTime += Time.deltaTime * speed;
value = Mathf.PingPong(totalTime, 1);
but I can't do this in Shader Graph. How to solve this problem?
EDIT1: I also try to create custom node fuction but this will result in error.
static string PingPongFunction(
[Slot(0, Binding.None)] Vector1 t,
[Slot(1, Binding.None)] Vector1 length,
[Slot(2, Binding.None)] out Vector1 Out)
{
return
@"
{
Out = Mathf.PingPong(t, length);
}
";
}
Upvotes: 2
Views: 16633
Reputation: 71
Feed time as x to sin(x) and multiply time with a number to speed it up.
Upvotes: 7
Reputation: 1011
I would do it like this pass your time into A
on the multiply node
and then you can either manually set B
to 2 to go twice as fast or add a new vector1 property so you can change it from the inspector.
Upvotes: 0