Rendering an Earth with 2 textures in cycles

Hi, this is my first post here, and I hope i am on the right place to ask this kind of question.

A short story:
How do I input (other) object’s world position into cycles node editor ? Or rotation, it can be heplful too.

A long story:
I am trying to render earth with 2 textures: one for day and one for night (city lights). I’ve tried to use shadow light paths and other stuff like that for blending factor, but without success. So I came with pretty basic mathematical idea: take the dot product of normalized light position relative to the object that is being lighted and normal of the surface, which gives me expected result. My problem is that I have to put manually light’s direction. But my Earth won’t be stationary, it will rotate and move along eclipse, so I can’t take the static position of lamp (in case in picture, sun’s position is 5,5,5, marked in red square). Does anybody have any idea how to do this ?

Or does someone have different approch for this problem then me ?

And for simplicity sake, in picture, let the blue shader represent daytime texture and green one nighttime texture.



There is the “Object Info” - Location value.

This Setup gives something like your looking for:

might need some tweaks.

Sun would need to be in Center of Blender Coordinate System…

I got your point. I don’t have exact nodes you are using I used vertex position, not object position, and it worked pretty well. I am using blender 2,63a, what version of blender are you using ? Also where did you find those nodes ? I couldn’t find them anywhere :S thanks for your answer :slight_smile: