Gradient horizontal help please

Hi All,
I have a Neon shader that I’m quite happy with, but I would like the main colour to be gradient running from left to right, starting with red, then orange and finally yellow.
I will be applying it to a rectangle 20mm Z by 5000mm X by 5mm Y
I know there’s a gradient node, but I struggle setting it up properly.
Any help would be great.
Cheers
A

I would not use the gradient node at all, use the texture coordinate node, and connect a “separate xyz” node to the “object” output. the x-output of the separate node then gives you the x-coordinate in object space with 0 being at the object’s origin. use the “map range” node to map that to the range of 0…1 and plug it into a color ramp:

1 Like

Thank you very much, for your help.
Please can you explain the map range node and how to understand the from Min, from max, to min and to max?
Is it to do with the physical length of the object? just thought I’d have a go at guessing :slight_smile:

The map range node has nothing to do with the object size, it is just a simple function between the input and output, looking like this:

the lower plot shows the behavior of the node when “clamp” is off.

the “smooth”, “smoother” and “stepped” options change the shape of the curve.

Why I used the node: the x coordinate of the object output of the texture coordinate node roughly ranges from -3 to 3 here, because, in this case, this is roughly the size of your object.

We want, however, a value between 0 and 1 to feed into the color ramp node. So what I did was connect the setup and then played around with the “from min” and “from max” values until the gradient fit the object.

Thank you very much for your time on this, it all makes sense now

1 Like