How can I map a gradient texture to another object's orientation with Cycles?

In the old Blender Internal render engine, if I wanted to make a model of the Earth complete with city lights on the dark night-time side, I’d just add the color texture map (plus specular texture map etc) and a night-time city-lights texture set to emission. Which is still easy to do in Cycles
But to get that texture to only effect the night-time side of the earth model, in Blender internal, I’d just add a blend texture, tweak it, and set it’s mapping to the sun lamp, and set it to stencil out the texture. (see first image) so no mater how the Earth or the sun lamp are rotated, the blend texture always faced the way the sun is pointing, so it only blocked the city-lights texture on the lit side of the earth model.
I already now how I’d do most of this in Cycles, using a gradient texture set to multiply out the lights texture. But how would I map that gradient texture to my sun lamp, getting it to match it’s rotation despite whatever position of the Earth model?

Thanks in advance.:slight_smile:


I fyou find an answer, I’m all ears - this is a long standing difference between the renderers.

UV Project modifier

uvproject.blend (105 KB)

Ah, thank you JA12! works beautifully. I greatly appreciate your help and insight. Did it just by looking at your screen shot, without looking at the .blend. Thanks so much again!:smiley:

very cool, will have to keep this screenshot