How to make a triangle wave

Hi,

First of all, please bear in mind I’m not a technical artist and my knowledge of math pretty much dates back from school.

I’m trying to achieve a flipbook interpolation in the material editor. For instance with that texture :

1885a5fc10b7593d912b22a760c4c301fedef638.jpeg

Basically I play the flipbook, then I play another copy of the flipbook that I offset by half the flip time and I use a sin to blend between each. It gives this :

example.gif

While that might be enough in 99% of the cases, it doesn’t really work with mine. Let me explain, I am making a vector displacement flipbook that plays ocean waves :

wave.gif

But because of the sin function, the interpolation between each step is not linear and that result in a slight stuttering when looked from up close. You can’t see it because of the gif framerate though
How could I make the sin wave a triangle wave like this?

2.jpg

I’m able to create such an effect using the time function as a base for masking, but then I can’t plug the time I use for the flipbook to sync the interpolation with the frame swithes…
Is there a simple math function that would make a sin function, triangle or at least close enough to it?

Cheers!

Google helps:
tri(t) = max(1-|t|,0)

I might be far off base on this one, but it looks like your half-flip algorithm is really doing sin(x) + sin(x +/- a quarter wave), which is sin(x) -/+ cos(x).

Try squaring the result of each flipbook. This will keep the result normalized, because sin(x)^2 + cos(x)^2 = 1, which might actually be the artifacts you’re noticing… not that it’s non-linear.

For anyone else looking for that (like me lately…) it’s:

arccosine ( cosine x )

If you divide it by Pi it will give you a triangle wave within the range of 0 and 1.