How to lineraly interpolate a value from 0 to 1, over time, and snap it back to 0 once it reaches 1

I’m trying to create a wave in shader graph. My approach is to create a hazy line and increase it over time from 0 to 1, and then snap it back to 0.

I’m having a lot of trouble achieving this in shader graph, and from what I found online, everybody seem to recommend exposing the property and manipulating it via C# code.

I still want to achieve this via shader graph, both for learning purposes and because it feels rather trivial to achieve, and I don’t want to add any unnecessary calculations to the CPU.

When using the LERP node, (I’d rather tween it, but let’s start with the basics), connecting the time node directly to the T input causes the whole preview to turn white. Multiplying time by any value doesn’t really change it. I don’t really understand the time output anyway, is it simply a growing integer? When connecting delta time, the preview flickers (understandable because delta time is usually a very small float). Sine and Cosine are producing desirable effects, but they both go from -1 to 1 and then from 1 to -1 (or vice versa), and I can’t figure out how to snap the value back to 0 when it reaches 1, and only increase it.

Anybody here can help me? I really do wish to have a more intuitive approach to shader graph, before I resort to good old C#

Thanks.

You should be able to attach the output of the Time node to a Fraction node. The Fraction node gets rid of the whole number portion of a value and just returns the decimal portion. So time will advance from zero to one. Once it reaches one, the Fraction node will throw away the 1 so the value will be zero again. This cycle will continue for as long as the project is running. Is that what you’re looking for?

This is exactly what I’m looking for