5

I have a couple of skyboxes in unity (Day and Night) and want to achieve a smooth transition between them periodically, to create a day and night cycle. I've looked up many questions but they're either outdated or I have no idea what they mean, Any help would be appreciated.

Umesh Konduru
  • 361
  • 1
  • 6
  • 19
  • [This answer](https://stackoverflow.com/questions/36386430/unity-3d-fade-from-one-skybox-to-another) is probably what you want to do. What shader are you using for the sky box? It would help to give me specifics and a better explanation. – leo Quint Apr 22 '20 at 13:11
  • @leoQuint I'm using a 6 sided skybox. I want to first render the day skybox. Then after a specific time, I want the day skybox to smoothly fade into a night skybox I have. – Umesh Konduru Apr 22 '20 at 13:30
  • Upvoting this question. It might be intresting for others too. I find the same question twice on the Unity forums, but also both without an answer. Mostly need-to-create-your-own-shader. – Blindleistung Apr 22 '20 at 16:05
  • There's apparently one on the unify wiki but I have no idea what it does or how I use it – Umesh Konduru Apr 22 '20 at 18:11

1 Answers1

4

Thanks for the comment responses.

I used this shader - http://wiki.unity3d.com/index.php?title=SkyboxBlended as suggested in an answer to another question. The problem is, a lot of beginners do not know how to use shaders, which I'm going to illustrate right now.

  1. Create a shader in your project, open it, and copy-paste the shader in the link above.
  2. Create a material.
  3. Drag the shader and drop it onto the material.
  4. (Assuming that you have imported your skybox textures) If you click on your material, it should let your drop 12 textures in the inspector window (6 for one skybox, 6 for the other)
  5. Now, by playing around with the Blend slider, you should be able to see your skyboxes fade into each other :). You can write a script to change the Blend value, to make an automatic day/night cycle, or season cycle.

If you want more help, feel free to comment

Edit : The page doesn't seem to exist anymore, but I'm sure you'll find a lot of shaders on GitHub.

Umesh Konduru
  • 361
  • 1
  • 6
  • 19
  • 2
    Was just wondering if you had any idea what the script to modify the blend slider would look like? Using a similar component and have been struggling all day to make the transistion smooth – Lewis Menelaws Mar 11 '22 at 20:45
  • I did this a long time ago and I honestly don't remember what I did. I just vaguely remember using Time.time - I set the blend value as a function of time passed and adjusted it to fit my game clock (1 min = 1 hour). It's been a long time since I've coded in unity but I can help you with the algorithm if you let me know what you're trying to do – Umesh Konduru Mar 12 '22 at 12:16
  • appreciate you getting back to me, I am trying to use a similar shader to cycle through skyboxes to show the player that they are progressing through the game. I am working as a team however and we had trouble with using the shader cross-platform windows and mac. Thanks again for the help. – Lewis Menelaws Mar 15 '22 at 20:00