function to generate the following signal

41 Views Asked by At

I don't know If this is the right place to ask but if not just tell me and I'll ask on another StackExchange forum!

I'm currently working on a tiny game project and I'm trying to generate a basic day/night cycle. To do so, I would like to create the following periodic function

The wanted signal

  • Where T1 is day
  • T2 is transition duration
  • And T3 his night

The value of the function fluctuate between 0 and 1 and is used with a color gradient to change the map texture and illumination.

For me, this looks like a mix between a triangle and a cyclic square wave. But to be honest, due to my lack of Mathematics skills I don't know how to process to put this wawe into a formula.

Thank in advance