# Is there a node that can separate colors by scale?

Is there a node that can separate colors by scale? I tried separate xyz but it didn't work.

Example:

What I get:

• By 'scale' do you mean 'distance to cube'? Aug 13, 2020 at 7:26
• like this: youtu.be/AHMxrmoAlA8 but using nodes Aug 13, 2020 at 7:44
• Are the cubes separate objects, as shown in the video, or one object? Aug 13, 2020 at 7:48
• one object, in the video I created another cube just to show the effect Aug 13, 2020 at 7:50

Well, this is one object, shape-keyed, but it has to have 2 materials, because at its fullest expansion, the inner cube has the same dimensions as the outer, so it would take a more elaborate node-tree to discriminate between them.

The inner cube has this material:

The maximum X,Y,Z in Object space gives the 'box-distance' to its surfaces. The outer cube has a radius of 1, the distance would need to be mapped to a different range for cubes of a different object-size. Scaling the lot in Object mode wouldn't do any harm, though.

I still can't be sure this is actually what you want... :)

• is exactly it. thanks so much Aug 13, 2020 at 9:05

The geometry node does what you want. The geometry node looks like this:

And has a vector output for position. The separate xyz node can be connected to that and it'll isolate the z component of the vector. Then you can use a math node set to greater than and a couple of mixRGB nodes to combine colors.

## What's a vector and why does this work?

Vectors are extremely important for anything procedural in blender. Simply, a vector is a combination of 3 components. In this case these components are x, y, and z. A color (having r, g, and b components) can also be considered a vector. The geometry node outputs a vector which maps x, y, and z for every point on the mesh. It's difficult to work with a vector, though, because it's hard to deal with multiple things at once. It's much easier to work with a scalar, or a single component of the vector. The separate x, y, z node separates a position vector into 3 scalars which you can modify with normal math nodes. There's also a vector math node which can be used in this scenario, but it's not as easy to conceptualize.

Here's the whole node setup which outputs a 1 for every point above 0.5 on the z axis:

• I had already tried with geometry and separate xyz. I just hadn't added the math but it did not work Aug 13, 2020 at 3:54
• @4b1m43l How big/small is your object? You may need a map range node to get the range between 0 and 1. If your object is 12 units high, blender will clip everything above 1 and you'll only see changes from 0 to 1.
– user74875
Aug 13, 2020 at 3:56
• not work -> see prnt.sc/tyqqpj the painting on the right is what to get, but without using selection faces and assign Aug 13, 2020 at 4:12
• Try the object info node, quick and dirty example: i.stack.imgur.com/Im7T8.jpg Also please take your time and edit your question: Add all relevant details like your screenshot, what you'd like to achieve, a minified blend file and what exactly does not work to your actual post, Thanks @4b1m43l -> How do I ask a good question? Aug 13, 2020 at 5:37
• this example contains more than 1 obj right? because it didn't work here! but it is exactly what I want. separate by scale Aug 13, 2020 at 5:53