0
$\begingroup$

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

Example:

enter image description here

What I get:

enter image description here

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

2 Answers 2

2
$\begingroup$

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:

enter image description here

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.

enter image description here

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

$\endgroup$
1
  • $\begingroup$ is exactly it. thanks so much $\endgroup$
    – 3D-ited
    Aug 13, 2020 at 9:05
2
$\begingroup$

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

enter image description here

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: enter image description here

$\endgroup$
5
  • $\begingroup$ I had already tried with geometry and separate xyz. I just hadn't added the math but it did not work $\endgroup$
    – 3D-ited
    Aug 13, 2020 at 3:54
  • $\begingroup$ @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. $\endgroup$
    – CtrlAltF2
    Aug 13, 2020 at 3:56
  • $\begingroup$ not work -> see prnt.sc/tyqqpj the painting on the right is what to get, but without using selection faces and assign $\endgroup$
    – 3D-ited
    Aug 13, 2020 at 4:12
  • 1
    $\begingroup$ 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? $\endgroup$
    – brockmann
    Aug 13, 2020 at 5:37
  • $\begingroup$ this example contains more than 1 obj right? because it didn't work here! but it is exactly what I want. separate by scale $\endgroup$
    – 3D-ited
    Aug 13, 2020 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.