Gradient based on relative direction

Hi.
I would like to map a normalised gradient on a mesh, for instance like if using the local position on the x axis (remapped to 0-1), but I want it aligned to a specific direction, towards a specific position in space or toward the world’s origin. Something I thought would be trivial in Amplify but I tend to get stuck even with simple maths.

To give a better idea: If we plug the result in the emissive port, every object with the shader would appear to be lit by a same object standing somewhere in the scene.

(I want to use this gradient to fake ambient lighting on a planet shader and light its atmosphere, according to its relative position to the star. For a matter of flexibility I would like to use a given transform position rather than using lighting informations. Also I would rather not use the normal information of the meshes since they are not so spherical.)

I hope this is understandable. I am sure it has to do with the nodes below but I ended up trying every combinaison I could think of without getting the desired result…

Any help would be appreciated. :slight_smile:

Well it seens I figured it out myself, with a simple dot product.

Not sure if this is the best solution but it does the job in my case. Here is the result what I was looking for: