# Cycles texture on sphere to follow sun rotation

I'm trying to make a cycles material for a planet in space, and I'm having trouble separating the dark-side of the planet from the light-side. I'm trying to relate it to the rotation of a sun lamp, such that I can mask it for daytime vs nighttime.

I've been trying drivers on the rotation fields of a vector mapping node, based on the rotation of my sun, but not having much luck.

Next go to the node editor and add the following nodes. The output on the right will be the desired gradient from facing sun's direction 1.0 to facing directly away from the sun 0.0. The three Value nodes on the left are driven by the empty's X, Y, and Z positions respectively.