I am wondering if it is possible to create a gradient with controllable number and positions of gradient central point. Something like freeform gradient in Adobe Illustrator.

Iâ€™m not familiar with Adobe Illustrator, and I donâ€™t think thereâ€™s anything built into Blender like that. But if I understand the tool correctly, you can build it yourself out of nodes:

Iâ€™m mixing (in linear RGB) between three different colors based on the relative, normalized distance between three empties. You can add as many empties to this as you want (hopefully, it should be clear enough how to do that.) You can reposition the empties or change the colors associated with them. It should be possible to mix other ways, but there might be some pitfalls-- not sure how youâ€™d handle a hue mix between three colors, two of which might be very very close but on opposite sides.

1 Like

Hi, thank you for the quick reply!
It indeed does what I asked for. But I would be very glad if you explain a bit more about vector math here (donâ€™t have understanding yet). In particular, what does â€ślengthâ€ť give as an output? As an input it uses â€śTexture coordinateâ€ť -> â€śObjectâ€ť, which uses coordinates of a point relative to the coordinate of the â€śEmptyâ€ť object (if I understand correctly). Does it mean that after â€śLengthâ€ť, instead of coordinates we have distances from the â€śEmptyâ€ť? As in the top left image below?

Now I tried to understand the nodes you show (using only two Empties) and got confused - I donâ€™t understand how you get relative normalized distance. To me it seems that you are normalizing to the reverse sum of the distances. Using your idea I would build the normalization a bit differently. I show it in the right top (your nodes) and right bottom (my nodes) images above (though the result looks almost the same). Please, correct me if I am misunderstanding something.

Even though the reply perfectly answers my original question, I realize that the question was incomplete. There are two things I would like to control. But maybe it is very complicatedâ€¦

1. I realized the problem with colors. If I have green, blue and red, their sum gives white. But with two colors that are not opposite on the color circle (red and blue, for example), I am getting blue+red=violet background everywhere away from the empties. What I want to have is some neutral transition color like white between red and blue.
I can demonstrate it (was done in Illustrator) in the left bottom image above. On the bottom, the gradient goes from red to blue, whereas above, two gradients are separated by white. In Illustrator I achieved it by drawing a white-gradient-line around the red-gradient point, so it is not just simple gradient)

2. Finally, I would like to control how quickly the gradient fades away from the center. In your nodes, the color changes as 1/distance, which seems very fast. Only at the empties the color is distinct. It would be better to have larger areas with dominant red and blue and small transition zone.

I know it is a lot of questions, I am exploring blender as I can, but here I am struggling and hope for some help.

Oh, I actually realized the normalization. That reverse normalization in your nodes equals b/(a+b) and a/(a+b). Somehow I did a stupid math mistake when I first checked it.

The length of the vector itâ€™s handed. You know, (x^2+y^2+z^2)=l^2 for positive values of l.

Thatâ€™s what it means, provided that the empty has regular old 1/1/1 scaling. (Itâ€™s actually distance from the empty, in the emptyâ€™s space.)

When the distance to an empty is 0, I want that emptyâ€™s weight to override all other empties. When the length is infinite, I want that emptyâ€™s length to lead to a 0 weight. Hence, Iâ€™m using 1/length. As length goes up, weight goes down. Thatâ€™s primarily so that I can use named empties in order to more easily demonstrate what Iâ€™m doing. If you create a third empty with your node group, youâ€™ll find that your â€śblueâ€ť empty doesnâ€™t actually mean blue, it means, â€śnot red.â€ť

You can do it any way you want. There arenâ€™t any rules. If it works the way you want, then itâ€™s right.

Then add another empty and make its color white.

Then use different math than 1/distance. Try running distances through math/power nodes fed by a single value node. The weights get normalized at the end anyways, so doing a power operation will only change the curve.

But if youâ€™d prefer, you can also do something to the normalized values, and then renormalize them afterwards. That would let you run them through three copies of an RGB curves node, which might be a more intuitive way for you to handle this.

It also occurs to me that this might not be exactly what youâ€™re looking for, even though it ought to be good enough for most use cases. Consider a sample way over there, almost infinitely distant from both empties, but still on one side. The node group I showed is going to give that an even mix, when youâ€™d probably prefer it to be fully the color of its side. The math for this is pretty simple for the two-color mix, but for any arbitrary number of colors, in 3D, Iâ€™m not convinced that itâ€™s even a well-defined idea.

1 Like