void Update()
{
// Rotate the sun and the moon.
float timeProgress = realToInGameTime(Time.deltaTime);
if ((dayTime += timeProgress) >= 24)
dayTime = 0;
transform.Rotate(0, 0, hoursToDegrees(timeProgress));
// Diminue l'intensité du soleil la nuit
float coef = -Mathf.Cos(dayTime/24f * 2*Mathf.PI);
coef = Mathf.Sign(coef)*Mathf.Pow(Mathf.Sign(coef)*coef, 0.25f);
coef = coef/2 + 0.5f; // To range [0, 1]
sun.intensity = sunMaxIntensity * coef;
}