- Home /
Help with Skybox Fading
Okay, what I want to do is fade from a night skybox to a day skybox upon the sun's rotation becoming in-between 0 and 90. I have done this fine for when it fades from a day to a night skybox, but for some reason when I want to change from night to day it just pops instantly in, without fading. Could I please have some help as to solving this issue? I am using the Skybox Blend shader. (The top if statement is day to night, the bottom one is night to day; the one I need help with.)
if(sunRotation <= 360 && sunRotation >= 270){
var blendAmount : float = timeOfDay * 0.5;
RenderSettings.skybox.SetFloat("_Blend", blendAmount);
}
if(sunRotation >= 0 && sunRotation <= 90){
var blendAmount1 : float = timeOfDay * 0.5;
if(blendAmount1 < 0){
blendAmount1 = 0;
}
RenderSettings.skybox.SetFloat("_Blend", -blendAmount1);
}
Some information about your shader and your variables would be nice. What's the range of timeOfDay and what value means what? If the timeOfDay directly related to your sunRotation and if so how (which angle means what)?
What's the range of your _Blend property of your skybox and which value means what? Using negative values seems a bit strange to me, but without the right information it's like shooting in the dark ;)
Answer by Statement · Dec 07, 2011 at 12:42 PM
Maybe you could use Mathf.Sin to adjust the value?
function SkyboxBlend(var degrees : float) : float
{
var radians = degrees * Mathf.Deg2Rad;
var sin = Mathf.Sin(radians);
return Mathf.Clamp01(sin);
}
function UpdateSkybox()
{
RenderSettings.skybox.SetFloat("_Blend", SkyboxBlend(sunRotation));
}
Your answer
Follow this Question
Related Questions
Day/Night Skybox 1 Answer
Blend two lightmaps for day/night cycle? (terrain) 0 Answers
Day Night cycle question 1 Answer
Day Night Cycle sun fade 1 Answer
Shader Blending Question 1 Answer