Hey, title might be a little confusing, but didn’t know how to phrase it.
Anyway, I’m making a day/night cycle using the blend skybox shader from the wiki and it works ok. I have it set up in phases: Night - Dawn - Morning - Midday - Night.
This works great, but when i try to loop it, the colours in my scene kind of “jump” from Night to Dawn. Like, one moment it’s blueish and the next it’s red.
Any idea why? Here’s my code:
BlendValue += (Time.deltaTime/timePerDay);
print(BlendValue);
rotatingLight.transform.localEulerAngles = new Vector3((BlendValue*360)-90,0,0);
if(BlendValue <= 0.5f)
{
blendedSkyBox.SetFloat("_Blend", BlendValue*2);
rotatingLight.color = Color.Lerp(NightColor, DayColor, BlendValue*2);
if(BlendValue <0.16666f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(NightTint, EarlyMorningTint, BlendValue*6));
else if(0.16666f < BlendValue && BlendValue < 0.33333f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(EarlyMorningTint, MorningTint, (BlendValue*6)-1));
else if(0.33333f < BlendValue && BlendValue < 0.5f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(MorningTint, MiddayTint, (BlendValue*6)-2));
}
if(BlendValue > 0.5f)
{
blendedSkyBox.SetFloat("_Blend", (1-(BlendValue-0.5f))*2);
rotatingLight.color = Color.Lerp(DayColor, NightColor, (BlendValue*2)-1);
if(BlendValue<0.66666f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(MiddayTint, MorningTint, (BlendValue*6)-3));
else if(0.66666f < BlendValue && BlendValue < 0.83333f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(MorningTint, EarlyMorningTint, (BlendValue*6)-4));
else if(BlendValue < 1f)
blendedSkyBox.SetColor("_Tint", Color.Lerp(EarlyMorningTint, NightTint, (BlendValue*6)-5));
}
if(BlendValue >= 1)
BlendValue = 0;