9
$\begingroup$

I'm learning Blender, and I want to make keys for a keyboard with RBG lights incorporated inside them (final render will be an image, not an animation).

I created a low-poly key, with 2 material : 1 for base color, and a second one for the random color. So here is what I did

Material settings

But now, i simply want to make an array to fill the keyboard. But the colors is not random at all, it stays the same.

enter image description here

$\endgroup$

3 Answers 3

14
$\begingroup$

Cycles

You can use parameter Random per Island

"A random value for each connected component (island) of the mesh. It is useful to add variations to meshes composed of separated units like tree leaves, wood planks, or curves of multiple splines."

enter image description here


BTW For "rainbow" ColorRamp you can set just a two colors (Red-Blue) with HSL > Clockwise.
Or for your full ring - Red-Cyan-Red. https://i.sstatic.net/Dq40Z.jpg

$\endgroup$
3
  • $\begingroup$ Cool, didn't know about this one :). $\endgroup$ Commented Oct 31, 2020 at 8:09
  • 1
    $\begingroup$ .. @JachymMichal Agreed! I instinctively thought it meant per UV usland, not per mesh island.. I couldn't imagine why Cycles needed this information.. still can't.. $\endgroup$
    – Robin Betts
    Commented Oct 31, 2020 at 9:18
  • 3
    $\begingroup$ @RobinBetts I think its super usefull. I was looking for this feature quite a long time :) Shame it is just for a Cycles for now. docs.blender.org/manual/en/latest/render/shader_nodes/input/… $\endgroup$
    – vklidu
    Commented Oct 31, 2020 at 9:27
13
$\begingroup$

Eevee / Cycles

You can change the array modifier UV settings:

enter image description here

If the UV map of the base object is between 0 and 1, shifting them by 1 in the modifier allows to get a integer part in the nodes (using "vector math/ceil" node for instance). Then get a color with "white noise texture" (or in a colorramp).

$\endgroup$
8
  • $\begingroup$ @vklidu Hi. your link is "undefined". $\endgroup$
    – lemon
    Commented Oct 31, 2020 at 17:36
  • $\begingroup$ @vklidu... ok, use "ceil" from "vector math", not from "math"! ; ) My bad... will edit my answer. Thanks to point that out. $\endgroup$
    – lemon
    Commented Oct 31, 2020 at 17:58
  • $\begingroup$ @vklidu, no no, this is not your attention. My answer said "math" (not "vector math") before I edited it following your result. $\endgroup$
    – lemon
    Commented Oct 31, 2020 at 18:29
  • 1
    $\begingroup$ Yes, but I could notice the violet header (or fact that UV is a vector input), but since nodes can be mixed often across logical hierarchy ... I was in my box :) $\endgroup$
    – vklidu
    Commented Oct 31, 2020 at 18:33
  • 1
    $\begingroup$ @Sophia, colorramp wants a factor between 0 and 1. So replace "ceil" by "floor" (to start at 0) and scale that by a factor (so that all above 1 is stretched back to one). For instance scaling by around 0.4 seems to work well in your case. $\endgroup$
    – lemon
    Commented Jan 14, 2022 at 11:57
3
$\begingroup$

Without the modifiers applied, all the "keys" are still considered one object. However, as you can see from the image below, even with the modifiers applied, the end result is still one piece (therefore nothing to randomize).

Array1

The solution is (after applying the array modifier(s)) to select the whole mesh (all the keys) in edit mode, and separate by loose parts. This will make all the keys into separate objects, though, so you will want to finish any array modifications first.

Separate

$\endgroup$
1
  • $\begingroup$ And what do you do if you have about 5000 objects in your array? And what if afterwards you want to adjust the array? $\endgroup$ Commented Dec 7, 2020 at 14:42

You must log in to answer this question.

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