# How may I get a single stripe of color to flow along an object?

I'm toying around and trying to get a single red stripe to flow along the length of a cylinder. I'm trying to copy ideas from this tutorial, but I can't quite get it right. I made a gradient with three colors (white, red, and white) and I've got the bands of color being produced alright, but they're a bit skewed and don't line up perfectly with the geometry.

My aim is to incorporate this into some sort of abstract looping animation.

Think of an LED strip, and having just a single LED light up and go down the chain. I want to achieve that similar look using a cylindrical object, and a stripe of color. If I could get it to work with a bent cylinder (like one along a curve) that would be great too.

Any ideas?

Here's what I've got so far:

• Could you add some illustrations? One colored strip or several? How the cylinder has to be bent? Commented Oct 15, 2020 at 14:45
• I added one to the main post, sorry about that. I'm trying to have just a single strip at the moment. I'd like a simple U-shaped bend for now. I'm trying to get the stripe to start at one end, and flow all the way to the other. Obviously mine isn't working that well right now, haha.
– n0ah
Commented Oct 15, 2020 at 14:52

We can use the "generated" coordinates (from "texture coordinates" node) property: the coordinates are given before any modifier deformations. Using it can simplify what we have to do here.

Or with several rings:

The base shape is a tube/cylinder with a simple deform modifier to make to U shape:

And the node setting is the following:

• Take Z value of the generated coordinates (remember this is still considered as a non bent cylinder)
• Substract it to some value that will be animated to move the ring(s)
• Keep positive value
• Multiply (integer values) to have the amount of rings
• Take module 1 to keep something between 0 and 1
• Compare the result to 0.5 with an epsilon that gives the width of the ring

The documentation about generated texture coordinates:

Automatically-generated texture coordinates from the vertex positions of the mesh without deformation, keeping them sticking to the surface under animation. Range from 0.0 to 1.0 over the bounding box of the undeformed mesh. See Texture Spaces for more information.

• Thanks a ton! I understand all of the math, except the very last bit with the compare node. This is a very helpful solution nonetheless. I appreciate your help!
– n0ah
Commented Oct 15, 2020 at 15:38
• Compare compares two values and the result is true if their difference is under epsilon. Commented Oct 15, 2020 at 15:40
• @lemon could you have a look at this one. blender.stackexchange.com/questions/197178/… Feel the same method could be used with 2x1 grid warp warp to make sphere. The map could be aligned to grid center clipped and distorted with nodes to desired lat long corner box. Commented Oct 15, 2020 at 16:19
• @lemon would it be possible to make the white strip an emission shader, while keeping the black part of the shape a regular diffuse shader? Could I just mix the two with a Mix Shader? Sorry for the add-on question, you've been a big help already. :)
– n0ah
Commented Oct 15, 2020 at 16:26
• @n0ah, yes: the result is black and white, so you can use it as fac for a mix shader. Commented Oct 15, 2020 at 16:28

Another way would be to use an empty and an UV Project modifier on the arc.

In your arch object, add an UV Project modifier and set the empty as the base object.

In your shader, separate the X coordinates of the UVs of your object, and add a Math node set to Compare around 0.5 to get a white stripe. The Epsilon value of the Math node controls the width of the stripe.

Result :

• Clever usage of UV project. Commented Oct 16, 2020 at 7:38
• It's definitely powerful for UV manipulation. :) I just wish it was a little easier to use or clearer what the settings do Commented Oct 16, 2020 at 7:49
• Oooo, I like this! Thanks!
– n0ah
Commented Oct 16, 2020 at 13:52
• @Gorgious is there a way to have the UV Project only affect the stripes material? I'm trying to set one material to be static for the shape, and then have a second material for the stripe. Currently, my static material is moving with the stripe. Is this possible?
– n0ah
Commented Oct 17, 2020 at 4:42
• Yes, you just have to use multiple UV maps. In the UV Project modifier you can set which UV Map to project to, and in the node editor, instead of the Texture Coordinate node, use an UV map node which lets you choose which one you want. To add an UV map to a mesh, go to the mesh properties tab (the icon with a downward facing green triangle), expand the UV Maps panel and click on the +. Let me know if you have trouble doing it Commented Oct 17, 2020 at 6:45

Here is a alternative to Lemon's solution, much more limited but works for simple object like the one you show. I create a plane, subdivide it, give it a Simple Deform and a Solidify modifier. Then I use the Texture Coordinate's UV output socket, and you use the Mapping X Location value to make the stripe follow the shape: