Dynamic Earth Day to Night in Cycles

To create a dynamic day to night transition for Earth or any other planet in Cycles, we’ll need to get the rotation data of the sun and plug that into the normal value of the sphere.

We can do this pretty easily by adding drivers to a mapping node between the input geometry node and the normal node. Here’s how to set up the drivers for each of the X, Y, and Z rotation values:

  1. Use the Sun as the Transform Channel variable object
  2. Set the Transform Channel type to the correspondingĀ X, Y, or Z rotation
  3. Use the variable name as the scripted expression
  4. To convert the radians back into degrees correctly, add pi to the variable
  5. Flip the variable for X and Z by using a negative sign and parenthesis

 

Cycles Nodes Screenshot