8
$\begingroup$

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:

Enter image description here

$\endgroup$
2
  • $\begingroup$ Could you add some illustrations? One colored strip or several? How the cylinder has to be bent? $\endgroup$
    – lemon
    Oct 15, 2020 at 14:45
  • $\begingroup$ 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. $\endgroup$
    – n0ah
    Oct 15, 2020 at 14:52

3 Answers 3

9
$\begingroup$

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.

enter image description here

Or with several rings:

enter image description here

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

enter image description here

And the node setting is the following:

enter image description here

  • 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.

$\endgroup$
7
  • $\begingroup$ 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! $\endgroup$
    – n0ah
    Oct 15, 2020 at 15:38
  • $\begingroup$ Compare compares two values and the result is true if their difference is under epsilon. $\endgroup$
    – lemon
    Oct 15, 2020 at 15:40
  • $\begingroup$ @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. $\endgroup$
    – batFINGER
    Oct 15, 2020 at 16:19
  • $\begingroup$ @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. :) $\endgroup$
    – n0ah
    Oct 15, 2020 at 16:26
  • $\begingroup$ @n0ah, yes: the result is black and white, so you can use it as fac for a mix shader. $\endgroup$
    – lemon
    Oct 15, 2020 at 16:28
6
$\begingroup$

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

enter image description here

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

enter image description here

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.

enter image description here

Result :

enter image description here

$\endgroup$
5
  • 1
    $\begingroup$ Clever usage of UV project. $\endgroup$
    – lemon
    Oct 16, 2020 at 7:38
  • $\begingroup$ It's definitely powerful for UV manipulation. :) I just wish it was a little easier to use or clearer what the settings do $\endgroup$
    – Gorgious
    Oct 16, 2020 at 7:49
  • $\begingroup$ Oooo, I like this! Thanks! $\endgroup$
    – n0ah
    Oct 16, 2020 at 13:52
  • $\begingroup$ @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? $\endgroup$
    – n0ah
    Oct 17, 2020 at 4:42
  • $\begingroup$ 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 $\endgroup$
    – Gorgious
    Oct 17, 2020 at 6:45
2
$\begingroup$

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:

enter image description here

$\endgroup$

You must log in to answer this question.

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