How to add a gradient of color to a line

Hi all,

I am struggling to wrap my head around the best way to add a gradient of color to a line. It seems like the simplest way is to use the ramp MAT, but I want the gradient to always follow the coordinates of the line in space.

IE if I think of the line as point 1 which I want to be red and point 2 which I want to be blue, I want the gradient to follow the line transitioning from red to blue, and I want that to happen no matter where I define the coordinates of each point in space.

It seems like the line material has this close and far color thing that is close to what I want, but I don’t want the line to get thicker and thinner because of the camera perspective.

Poking around, it seems like the point chop should also be able to do this, if there was some way for the color of each point to be defined by its index and have that affected by a ramp, but I can’t wrap my head around how to do it.

I assume there must also be a way to do this on the MAT side by transforming a ramp to always follow the two points of the line in space

I will attach the flow I have right now, I am quite new to touch designer so any and all feedback is appreciated, thank you.

LineGradient.toe (6.7 KB)

This can be done by dragging the ramp TOP to the Color Map parameter of a constant, phong, PBR MAT etc. I’ve included your edited file below:

LineGradient.1.toe (6.8 KB)

Totally right…and I appreciate the speedy response.

Unfortunately with that solution I immediately run into another issue. I was trying to use the line material because I want to change the thickness of the lines easily. I was thinking that using the constant material also wouldn’t be bad, I just have to use the linethick ob.

However, the color map doesn’t seem to work with the linethick object, where instead of overlaying the gradient onto the line, it seems to overlay the average value of the color map (which in this case is orange, instead of a gradient).

I either would need to find a way to put the color map on the line material for a gradient, or figure out how to change the thickness of a line drawn with the constant material while still keeping the gradient.

Here is an edited patch that has an example of what I am talking about.

LineGradient.5.toe (7.2 KB)

TextureSOP behind your linethickSOP?