Search Unity

Day/Night Cycle

Discussion in 'Scripting' started by brayT, Aug 5, 2019.

  1. brayT

    brayT

    Joined:
    Jan 21, 2018
    Posts:
    65
    Hey guys i would like to know if you guys could show me how to make a day/night cycle for my game... now i see that everyone's using a procedural skybox for all the tutorials i've seen... but could you explain how i could do the same with a 6 sided skybox?
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    When you are using a procedural skybox, your shader is generaiting all pixel Information for the background (usually some color dissolve for the horizon, plus main color). That way you can control the background color which you can adapt to the time of the day by passing different colors to the shader.
    A six-sided skybox uses a different shader that derives the pixel color from 6 Images instead of calculating it. You could (and some skybox shaders provide controls for that, e.g. using Tint and Exposure) change the overall tone and brightness of the Images to adapt for day/night, but in most cases, it would not look good (if your skybox also has a sun in ist imagery, you'd also have the added problem of having the sun up while the light grows dark).

    You'll end up writing your own shader that processes the skybox imagery, bringing you back to the procedural skybox.
     
    brayT likes this.