Array with each object having different colors?

Hello,

Lets say you have an array with 6 objects, can you give them 6 separate colors?
It’s been some time since i used Cycles but i thought you could do something like in my screenshot for this.
But i can’t get it right.

Anyone know how to do this?


Array-6-colors.blend (508 KB)

Cheers

1 Like

Either apply the array and then separate by loose parts §

or use a particle system.

It cannot be done with an array modifier active.

Thanks,

I’ve tested apply the array and separate by loose parts but the only thing i seem to get different colors with is from the random output and that doesn’t produce the six colors or in the order the colors are setup.
I want the six objects to have the exact six different colors in the right order.

Should be possible right? :o

I think u need to divide by 6. Not .6

I think it can be done with material index.

Here I just applied the array and used this setup on the object as a whole without separating it. I had to slide the yellow over a tiny bit.


1 Like

Thanks BoFZeVampire and Photox both your tips worked.

@BoFZeVampire that’s quite a complicated node setup, how do you even know how and what to use for getting the end result? very impressing.

Hi,
Not quite sure it’s OK.
The objective is to map the UV coordinate to the color ramp.
from 0 to 1: we want 0.5/6 /* first color /
from 1 to 2: we want 1.5/6 /
second color */

from 5 to 6: we want 5.5/6
from 6 to 7: we want 0.5/6
from 7 to 8: we want 1.5/6

so the formula is: ((trunc(UV) modulo 6)+0.5) / 6
the function trunc(UV) does not exist so I used the value minus the (value modulo 1). (for example 2.23 gives 2.23 - 0.23 = 2)
The mapping node is useless.

Who said anything about uv space? python is overkill for this.

Could say that but that’s why it doesn’t work. Array modifier does not array objects, it arrays object data (mesh). You have 1 object with 6 mesh parts, that object gets one object index (probably default 0) and dividing 0 with 0.6 gives 0, which is the first color in the ramp.

To add to other answers, could also do this with procedural duplication. Instead of arraying (mesh) this uses instances of objects and it’s possible to use parent’s coordinates to get a single color for each.


Duplifaces are used. Basically single planes where duplication puts a cube on each face. Those faces are UV unwrapped.

The material is for one cube and coordinates come from the parent object with the ‘dupli’ option. We’re only interested in U axis of UV coordinates. Top set of cubes uses the shown color ramp, bottom ones use different UV’s from parent and hue saturation node to get a different range of hues with an offset.

Array-6-colors-ja12.blend (93.8 KB)

HI,
No python code was used in the making of my .blend file.

@JA12 thanks for yet another great solution :yes:

Ok I see, sorry. I wasn’t trying to diminish it, it’s valid and a working solution.