1
$\begingroup$

I would like to dynamically change the color of instance objects based on their rotation value using Geometry nodes.

Specifically, I'd like to do the following:

For each instance, detect its rotation (preferably Z rotation or a specific axis).

If the rotation is between 0–120 degrees, make the instance red. If the rotation is between 120–240 degrees, make it green. If the rotation is between 240–360 degrees, make it blue. 

I've tried using color ramp, but can't seem to map the rotation degrees cleanly to these ranges for the color output.

img1

img2

img3

See attached Blender 5.0 Blend File

$\endgroup$
1
  • $\begingroup$ Your RotFactor attribute goes from (approx) -9 to -7.5. I'm assuming that's not what you want ? Also, in the shading nodes, your attribute is set to Geometry, but it should be set to Instances. Correcting these 2 points will solve your issue. I don't have the time to rework your nodes sadly, at least at the moment. Hope it's enough for you to solve it. $\endgroup$ Commented 8 hours ago

1 Answer 1

2
$\begingroup$

Result

Three important things:

  • Using the "Instance Rotation" node should probably be quicker than calculating all the rotations again
  • Remember negative angles exist, so you gotta wrap them within the range you're expecting
  • The shader needs the attribute to be set to "Instancer"

Geometry nodes

Shade nodes

$\endgroup$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.