10
$\begingroup$

I have a curve, which has been made visible by using a circle as a bevel object. I would like the color to change along the length of the curve. In other words, the curve will start red, and then change to blue towards the end.

I have figured out how to make the color change as a function of a coordinate (in this case the x-coordinate), but I cannot figure out how to get the coordinate along the length of the curve so that I can pass it to the ColorRamp.

enter image description here

enter image description here

Any ideas?

$\endgroup$

2 Answers 2

17
$\begingroup$

The trick is to enable UV mapping on the curve and then use UV as the input texture coordinate. Then use can use the mapping node to rotate the default UV positioning to get the gradient to run along the length of the curve. Please note I had to adjust the X/Y scale factor to get the whole gradient to show on the curve.

enter image description here enter image description here

$\endgroup$
2
  • $\begingroup$ Yes, this seems to work! Thank you! (and nice animation!). To be specific, UV mapping is enabled via clicking the "Use UV Mapping" in the "Texture Space" section of the "Curve/Data" tab. In the Mapping node, I found that I could leave the "Rotation" at zero for x,y,z. Also, I just used the "X-scale" and left the others at zero. Using the y-scale caused the colors to look strange. Thanks again for your help! $\endgroup$ Apr 26, 2016 at 20:51
  • $\begingroup$ Thanks, I was so long looking for this :-D how did you come to those degree values? Sometimes it´s hard to figure out the right ones especially on tiny geometry ... $\endgroup$
    – Kristo
    Mar 5, 2018 at 19:44
7
$\begingroup$
  • Material - plug UV Texture Coordinate socket into Separate XYZ node
    and use X socket as Fac input of ColorRamp

enter image description here

Note: Add thickness to a curve (make a tube) you don't need another object for circle profile - just go to Properties editor > Object Data > Geometry > Bevel > Depth

$\endgroup$
0

You must log in to answer this question.

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