# Generate Particles with Random colors (continuously or from a set)

I am trying to do rocks and I want them to have a random base color from within the colors that look "rocky". The only method I know of is to duplicate the base objects over and over and give each a different color in the node editor, then group them all and use them as the group input for the particles. This is slow, inefficient to change, duplicates a lot of data, and comes out with a uniform distribution of the colors. Is there a way to have give particles a random color from a set or range?

• The first 2 answers together make up a pretty complete solution for this (read both; part of one answer is fixed in the other). There isn't a way to make both as the answer, though. Jan 8 '17 at 3:05
• wouldn't the second answer be the correct one since it's building on top of the first one? Aug 17 '19 at 13:30

I'm going to keep this short and simple. Do everything Duane Dibbley did but use an Object Info node instead of a Particle Info node. Connect the random output directly to the color ramp, no math node needed.

Pro Tip: Make sure that if you are using a color ramp set to constant that you don't put any colors at position 1 (all the way to the right). They won't end up being used.

• Apart from being marginally simpler than my setup, it doesn't make much difference. The randomness still isn't random enough. +1 for noting that position 1 won't get used (though with my math node, exactly one particle will get the colour at position 1).
– user27640
Jan 4 '17 at 4:19

In Cycles, you can achieve this with a Particle Info node and a color ramp. It has an Index output socket, which gives you a integer from zero to one less than the total number of particles emitted, so you'll need to divide the index by one less than the total number of particles, to get a value between 0.0 and 1.0 which will drive the color ramp. This material goes on the dupli object, not on the emitter. If you set the particle emission to Random, each new particle emitted will appear in a random location, meaning the indices will not be ordered. This in turn makes the differently colored particles appear randomly accross the emitter.

The color ramp can be defined in several different ways: Ease, Cardinal, Linear, B-Spline and Constant. With the first four, the colors will smoothly transition between the control points, and they differ only in what formula is used to calculate the transition, and with Constant the color changes abruptly at each control point and remains unchanged between the control point (any point which is not a control point will have the color defined by the control point to its left). I will show Linear and Constant here.

This is with Linear

Here's a rendered preview of a very bland scene with only a plane emitting 250 duplicates of the same object, using a linear color ramp.

This is with Constant

Here's a rendered preview of a very bland scene with only a plane emitting 250 duplicates of the same object, using a constant color ramp.

• This isn't quite it. It creates a RANGE of colors, which covers a lot of situations. But it doesn't create a SET of colors. Fine for the rocks. But let's say you want to make sprinkles for a donut. Sprinkles need to be in specific colors, not just a range, or it looks wrong. You need to pick a set of colors (ie 5 specific shades) and have them randomly distributed. Jan 1 '17 at 17:13
• @Elliot Set the color ramp to Constant instead of Linear, and define more distinct colors. You can have up to 32 if I'm not mistaken.
– user27640
Jan 1 '17 at 17:15
• Thanks, that all works except that even though I set it to random it's still just grouping spatially (seems to be making the particles in order across the surface). Since I previously had all this generated and I'm just changing settings now (and I cut the group back to just one of each shape), do I need to do something to force it to reseed the particles? Of course since I'm doing fixed objects I am in hair mode, not emitter; does that matter? Jan 1 '17 at 17:26
• @Elliot If it wasn't set to random before, and the particles had been baked, you need to free the bake and bake it again. If they weren't baked, try going to frame 0 on the timeline, and then scrub the timeline (i.e. play it). If that doesn't help, try playing with the jittering amount and/or try disabling/enabling Even Distribution.
– user27640
Jan 1 '17 at 17:33
• I've tried this. Nothing I can figure out to do will make them come out random. The spatial distribution holds in every case except Emit From: Verts, which gives random distribution but otherwise fails to look like anything reasonable. Jan 1 '17 at 18:06