Generate gradient with sine/cosine?

I need to generate B&W gradients that go from black to white and back to black again with a dynamic number of repetitions. Is there a way to do this with just expression nodes?

Being able to use sine/cosine would be ideal, if possible.

There’s literally a node called sine in the material editor. In it’s input you should, of course, use time. If you want the transition to be faster you should multiply time by how much faster you want. Enjoy!

I’m sorry, I think I explained myself poorly. I’m familiar with using sine to do a pulsing action for something over a period of time, but what I need is a linear gradient (and a sine curve fits the characteristics of the transition from white to black to white perfectly). The sine function itself, as far as I can tell, doesn’t output a gradient.

For example, if I were using photoshop styles for gradient I’d have 0,0,0 at the 0% mark, then 255,255,255 at the 50% mark, and then 0,0,0 at the 100% mark. I’d like to be able to generate something similar in a material node, if possible.

I figured it out! Send a LinearGradient’s output into the Value (S) of LinearSine. If using the RoundedLinearSine output, you get the nice, gentle transition a sine curve provides.

https://docs.unrealengine.com/udk/Three/MaterialMasks.html