15
$\begingroup$

I want to create a chain that alternates between two colors every x chain link. This is what I want to model: Chain with alternating color chain links

The best I could do was use the wave texture node, but then I get chain links that are half orange half black: Using wave node to create alternating color

Of course, I could just apply the array modifier and change the texture of every x set of chain links, but I want to have the option of later varying the chain length.

Thanks!

$\endgroup$
0

3 Answers 3

20
$\begingroup$

Array modifier has a UV offset option. If you shift each instance by one in U in the modifier:

enter image description here

then, you can use this information in the shader:

enter image description here

In this example, the step value is 5.

We divide X from the UV by five, take the floor of the division then modulo it by two to alternate the colors.

So that:

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks to all who posted their solution. But now I am facing a new problem. I hadn't UV unwrapped my object before. Now after applying all modifiers and then UV unwrapping, the whole chain turns orange. Can someone explain what went wrong? I am using lemon's methond, btw. $\endgroup$
    – Toni
    Commented Oct 14, 2020 at 12:31
  • $\begingroup$ Hi, all methods are nearly the same and all are based on the array modifier "Offset U" option. So, simply, none of them will work if you did not use this option before applying the modifier. $\endgroup$
    – lemon
    Commented Oct 14, 2020 at 12:40
18
$\begingroup$

I like both of the above answers, but I think, (so long as you can trust the user to put integers into the input variables,) because UV's can exceed the 0-1 range, the tree can be simplified:

enter image description here

If you wanted it to be more goof-proof, you could Floor the inputs.

$\endgroup$
5
  • 2
    $\begingroup$ That's awesome. Plain and simple. $\endgroup$
    – Joonas
    Commented Sep 27, 2020 at 17:56
  • 1
    $\begingroup$ Well... was about to edit following my comment below @Joonas answer... but you were faster, $\endgroup$
    – lemon
    Commented Sep 27, 2020 at 17:59
  • $\begingroup$ Sorry, @clutch, I can't count the number of times you've beaten me :) $\endgroup$
    – Robin Betts
    Commented Sep 27, 2020 at 18:02
  • 2
    $\begingroup$ mmm... how is it possible that @ clutch pings me here? have @batFINGER and yourself brided our moderator to make that possible?? $\endgroup$
    – lemon
    Commented Sep 27, 2020 at 18:09
  • $\begingroup$ simply awesome! $\endgroup$
    – Chris
    Commented Apr 26, 2021 at 6:03
8
$\begingroup$

I really liked Lemon's answer but I also like a little more control.

Nodes

This note network is more complicated but it also gives you more control. There are two value nodes you can change. You can change how often the color changes and if another color stays on for longer. Also remember to change the Array modifier UV Offset to 1 for U.

Change repetition speed

Change color length

$\endgroup$
4
  • $\begingroup$ +1 for the idea. But if I understand well, this is a way to have a distinct links amount per color? If yes, this can be much more simple node setting. $\endgroup$
    – lemon
    Commented Sep 27, 2020 at 17:42
  • 3
    $\begingroup$ @lemon Yeah. My idea was to have chains output integer values and continue from there with a sine wave. That was quite unnecessary as mr. Betts demonstrated. $\endgroup$
    – Joonas
    Commented Sep 27, 2020 at 18:22
  • 1
    $\begingroup$ We should definitely have animated chains out in the real world! $\endgroup$ Commented Sep 29, 2020 at 19:51
  • $\begingroup$ @Thomas Weller Definitely. That would be so cool. $\endgroup$
    – Joonas
    Commented Sep 29, 2020 at 19:54

You must log in to answer this question.

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