Is it possible to orient the material of an object to always point towards another?


Hi,
Thanks for reading.
I would like to create a material with a gradient, in which the gradient originates from the bottom centre of the object, and always orients itself to an empty. So that the empty becomes sort of a sun. Is this possible?
Thanks!

I believe object texture coord with the empty linked, driving the gradient will do the trick. We’ve done diffuse and phong shading based on a linked position in the past.

1 Like

Hi Carl, Thanks for the reply. It`s much appreciated.

Based on what you said ive tried to set it up, but this is as far as I have gotten, and then my knowledge of Blender expires. I`m not sure how to make the materials rotation be defined by the position of the empty in the worldspace.

Can anyone suggest how to proceed?

Here is a simple starting off point:

2 Likes

Hi Pyblend
Thanks for the help. That is exactly what I was looking for. But the way to achieve it was way beyond my current knowledge. I had never seen the vector math node before. Looks like I have got some learning to do. Thanks again.

1 Like

Hi,

I have recreated your material and made, what I assume is a dirty noob hack to add color, so far I have achieved this effect:


I am happy with the result. But the additions I made do not allow for me to control each color in the gradient individually, nor how steep the gradient is between them, as I would like the gradient to be more gradual. Here are my additions to your material.

Can you suggest a way this might work?
Thank you.

Yes, it is possible, it just takes a little more work.
LightGradient.blend (607.3 KB)
I’ve added the .blend because I don’t think a screenshot would help.
There should be a text file in the .blend explaining the material.
Let me know if this works.

2 Likes

I am speechless, this material is amazing. Its smooth gradient 2 tone gives a perfect flat feel that makes the object feel 2D. I can control the gradient strength with the divide math node and perfectly dictate both colors with the color ramp. I can also alter the gradient location and rotation per material by simply parenting it to a different empty. It`s exactly what i was thinking of when I posted the question. Thank you.

I also must thank you for taking the time to make a detailed explanation of the material, I have learned a lot from it.

Here are a few objects I have made previously with the shader applied.



These models were not made to use this material but it works very well, however I do think better results would be achieved with this material in mind when modelling. Specifically, defining each object by its color and keeping each color a single mesh.

Thanks again.

2 Likes

Another possibility is to use the Empty coordinates directly (without subtracting the object coordinates). That will let to use the empty location and size directly to set the gradient…

In this example, the start of the gradient is the empty origin, and the end of the gradient is the tip of the Empty arrow (it’s a simgle arrow empty for better visualizing the gradient).

2 Likes