- Home /
Day/Night cycle transition help?
Hi, beginner here. What im trying to do is make a simple day/night cycle,i followed this guys super simple tutorial and it worked great, however i would like to know how to make the day skybox slowly fade into the night and same with the night into day. And also even maybe how to make a sun that sets and rises?
Any help would be greatly appreciated, thanks.
Answer by getyour411 · Aug 19, 2013 at 01:08 AM
Try BurgZergArcade's Day/Night cycle tutorial parts; sets up suns, moons, fading in/out skyboxes, sunrise/sunset, demo's how to get a custom shader from wiki, even adding an Editor menu, etc. It's a great series as a whole, but the parts covered in these bits speak directly to your question.
Thats a really good find. I had a vague memory of there being a day-night cycle tutorial but had no idea about the custom-shader from the Wiki. Written by Aran Prankecivus no less...Up-voted.
Answer by AdenFlorian · Aug 18, 2013 at 10:43 PM
Fading Skyboxes
To do this you could use a shader that holds two textures (or sets of textures), and a range slider that controls the fade in between the two (usually by changing the opacity of one of the textures).
I found this tutorial on shaders to be a great introduction.
Part four of the linked series covers blending two textures with a range slider, but you should probably go through all of the previous ones if you are new to shaders.
You can see it demonstrated here.
Rising Sun
Two methods to do this I can think of are using a flare with a directional light (or any light, and just rotate it around the level), or a texture that is being rotated around the level.
The simplest is to use a directional light with a flare assigned to the flare slot on the component. When you rotate the directional light it places the flare in the sky at where the light is coming from. A Light Flares package comes standard with unity. Import that and use the sun flare on the directional light.
I hinted at a shader approach as well, but given that the existing skybox shader alone is quite complex, expecting a beginner (or even moderately good programmer for that matter) to be able to also add further textures + fade-ins, is asking much.
The rotating directional light approach is correct though. I missed that part of the question.
Your answer
Follow this Question
Related Questions
Errors with ENDCG in shaders 1 Answer
fading between skyboxes 1 Answer
Skybox Transition 1 Answer
Change/Fade between two skyboxes? 1 Answer
How to make/use Skysphere 3 Answers