Advertisement

You're blocking ads, which pay for BlenderNation. Read about other ways to support us.

Creating a Day and Night Cycle in Blender 3.1 Cycles

3

Kaizen Tutorials writes:

Hey BlenderNation, welcome back to another tutorial!

In this one I’ll show you how to setup a basic day and night cycle world shader. Just using the sun position add-on, some world shader sky texture nodes and some additional nodes to create stars. Super simple, but very effective and giving pretty realistic results!

Hope you enjoy the video. If you do be sure to check out my other tutorials on Blendernation, or directly on my Youtube channel!

Cheers,

Kaizen Tutorials

About the Author

Kaizen Tutorials

Hi! I make Blender tutorials for beginner and intermediate levels. They vary in subject and difficulty but are all aimed at creating good looking results within a short span of time!

3 Comments

  1. Here are my suggestions for improvement on this node setup:
    1) Fixing Nishita's brightness.
    a) Create a driver to replicate elevation into a value node.
    b) use the map range node to convert elevation from frommin/frommax -pi/2 & pi/2 to tomin/tomax 0 to 1.
    c) Plug this into the value input of a float curve. Set the points of the float curve to (0,1) (0.5,0) (1,1) (makes a bowl).
    d) Plug this into the strength of the background of the day sky.
    2) Use elevation to control changing from day/night.
    a) Create a driver to replicate elevation into a value node.
    b) Remap this from frommin/frommax -0.25 & 0.25 to tomin/tomax 0 to 1.
    c) Add a math node and subtract b from 1.
    d) Feed this into the Fac node for the mix shader for day/night.
    3) Make the star position comply with sun elevation.
    a) In front of Noise texture, add mapping node.
    b) In front of mapping node, add Vector Rotate, plug into Vector for mapping.
    c) For Vector Rotate, plug texture coordinate Generated into Vector Node.
    d) Add driver to replicate latitude to a value node.
    e) Use math node to convert to Radians.
    f) Use combine XYZ and plug the Radians value into Y.
    g) Plug the vector from the combine xyz into the axis for Vector Rotate.
    h) Add driver to replicate elevation - plug this into the Angle node for Vector Rotate.

    Now everything is working as a function of the time of day, working independently of the timeframes.

    I'd love to have improvements in the form of textured moons, moon phases, eclipses, weather, etc.

    There are a couple plugins that do some of these.

    • Came back to report on an error in step 3.
      Because elevation in Blender is cyclical with the time of day, feeding the elevation into the axis rotation is incorrect.

      4) Make star location a function of time (not elevation). Omit "3h" step from above.
      a) Right click on time in sun position tab, add driver.
      b) Add value in node editor, paste driver. Rename to "Time."
      c) Add math node, modulo type. Feed "Time" into first value. Set second value to 24.
      d) Duplicate modulo math node and change to divide. Feed value from c into this node.
      e) Duplicate divide node and change to multiply. Multiply d by 360.
      f) Duplicate multiply node and change to "radians". Convert e to radians.
      g) Feed radians into "Vector Rotate" Angle into 3g above.

      Notes:
      I make the point of multiplying by 360 (to create degrees), and then convert to radians, and then feed into Vector Rotate on purpose, because this is perhaps something BF could fix.

      • Amazing stuff, thanks for taking the time out to create this post. I didn't want to make this too daunting of a tutorial so I opted out of doing all fancy driver stuff. But it's great that you point it out, since it's way more procedural this way.

        There are amazing add-ons which will allow for all of this aswell, but I always feel like doing stuff yourself, even if you're not going to use it in the end is the best way to learn.

        Thanks again for sharing your insight and knowledge!

Leave A Reply

To add a profile picture to your message, register your email address with Gravatar.com. To protect your email address, create an account on BlenderNation and log in when posting a message.

Advertisement