Is there any way to change the location of a gradient texture with "mapping node" using distance in percentage instead of distance in meters? For example, I need the gradient texture to be always in the center of the object (x and y coordinates). Even when the array modifier is applied to the object. And this material is used by several objects of different sizes.

Something like on this picture:

NOW current texture example

MUST BE enter image description here

Additional info:

  • Eevee
  • NOT as a postprocessing effect.
  • 4
    $\begingroup$ Have you tried the Generated coordinates ? $\endgroup$
    – Gorgious
    Jun 29, 2021 at 8:35
  • $\begingroup$ yes :) I tried many other things $\endgroup$ Jun 29, 2021 at 8:38
  • $\begingroup$ Maybe if you used geometry nodes instead of an array modifier, and then you could use a python driver to control the material… $\endgroup$
    – TheLabCat
    Jun 29, 2021 at 11:31
  • $\begingroup$ There are flaws with my method, I'll try again. $\endgroup$ Jun 29, 2021 at 20:42

1 Answer 1


I find that this is possible given certain constraints.

If you are not using the Array Modifier to scale the object.


If your object's coordinates do not intersect each other over the axis you're wanting to use.

For example, in my test scene I have an array of 5 cubes that do not share any space on any axis of the coordinate grid.

enter image description here

This way we can make it repeat without overwriting a portion of the previous object. You only need to clear the object on the axis you want to use for the shader.

I found a pretty robust way to do this is to use an Object Offset for the Array Modifier.

enter image description here

We can start with two Texture Coordinate nodes to reference both the Cube and the Empty, and Subtract their Object Coordinates. We then need to Vector Math -> Divide this result by 2 in theory, but in practice it's better to divide by some value slightly larger than 2. I used 2.0001 which is truncated to 2.000 in the UI, but it's important to know because it solves some floating point precision stuff that can pop up.

enter image description here

And it generates this intense white color, which is at first glance not very useful to us, but now we can use either the Vector Math -> Modulo OR Wrap node to make the Cube's Generated Coordinates repeat over the distance between the Cube and the Empty on each axis. Maybe someone with an advanced math degree can take this even further.

enter image description here

enter image description here

SO... to answer the actual question, finally, it's all of that, and then your subtract operation.

enter image description here

  • $\begingroup$ Different sizes is a different beast. $\endgroup$ Jun 30, 2021 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .