How would I change a Cycles material's color using the scale of the object instance it's applied to? Basically I have a field of spheres that are a bunch of different sizes that use the same material and I want them to be a different color based on their size.


I'm using a volumetric shader, so each of those little clusters is one sphere.

I accomplished something similar to what I want by using the Object Info input node's position attribute. It looks like this. Unfortunately the Object Info node doesn't have a scale option. Is there a way to add that? Or perhaps some method using drivers? I'm still not very good with drivers so maybe I'm just missing something.

atomicbezierslinger has suggested a way to change the color of a particle based on its size, which is an interesting solution, and it worked well. 


I'm not very experienced with particle systems, so I basically manually went through to each sphere and gave it it's own particle system that emits 1 particle from its volume and with no physics. I manually changed the size of each particle then shrunk the emitter sphere down to .01 so it would be in about the right spot. I'm feeling a bit like a monkey on a typewriter but it got the job done. 

My problem is solved thanks toatomicbezierslinger, but I would still be interested in whether or not it's possible to not have to use particles to do this. I can't be the only person to have this problem and the method I used wasn't exactly fast.

Perhaps there's a way to use Object Index on the Object Info node by assigning an index to each sphere based on its size using a script of some sort? I don't know the first thing about python, so I wouldn't know.

I'm using blender v2.76b, by the way.
Cycles Sample 01



Cycles Sample 02



Consider a particle system and material shader nodes.

Use the particle info node size [relative scale] value.

Note the object particles with [size] set to 1 and [random size] set to 1 in the image below.


We assume that your placement of spheres can use a particle system.
Particles are emitted in 2 frames.  Of course with a more complex mesh particles can be placed anywhere.  There was no artistry in placement of the example I provided.  You can do better.

Below same Material with different Particles Settings. A more controlled placement with particles spaced evenly.