2
$\begingroup$

I have a node setup that creates a new instance of a ring for a set number of points, where each instance is scaled incrementally.

Now I want to set each ring to have the next material in the material index, set respectively. In other words, the first ring gets Material Index 1, the second ring gets Material Index 2, and so on.

I have set the Material Index for each material accordingly, and I've got the Set Material Index node set up to the best of my knowledge, but it doesn't work. What am I missing here?

PROJECT FILE

enter image description here

NOTE: There are similar questions, but the answers are very convoluted. From what I've gathered online the solution should be pretty simple, so I'm hoping for an elegant answer that doesn't involve realizing instances, extracting the data, then deleting the realized instances and plugging in the data to a bunch of nodes... etc.

$\endgroup$
4
  • $\begingroup$ This one could be helpful: Geonodes - How to use Material Index? $\endgroup$
    – quellenform
    Commented Nov 27, 2022 at 21:39
  • $\begingroup$ @quellenform thank you for that original answer to my question. Unfortunately in my case it doesn't work with my Instance on Points node setup. I have tried to amend your nodes to mine but I just can't figure it out. Would love if you could enlighten me as to how to make this work with the current project, thank you!! $\endgroup$ Commented Nov 28, 2022 at 0:13
  • 1
    $\begingroup$ I hope I'm wrong and someone writes an elegant answer, but as far as I can see there's no way around doing tricks like in quellenform's answer since Material Index node only supports the face domain. From the manual: "Currently the node supports mesh data, where material_index is a built-in attribute on faces", and "Selection: Whether to change the material index for each face". Even when you do stuff like this it ends up coloring faces, not instances. $\endgroup$
    – Kuboå
    Commented Nov 28, 2022 at 9:19
  • $\begingroup$ @Kuboå this makes sense, thank you, I did not realize that the Material Index only used faces. I've been banging my head against the wall over why this won't work :( $\endgroup$ Commented Nov 28, 2022 at 17:26

1 Answer 1

2
$\begingroup$

As @Kuboå has already pointed out quite correctly: There is (currently) unfortunately no way to apply a material index to individual instances.

But there is another way to achieve the goal without Realize Instances:

enter image description here

The catch is, however, that this only works from version 3.4, because only from this version it is possible to store attributes also in instances!

The basic principle here is, that I simply map the index of the instances to a range of $0-1$, and use this value as Fac in the shader in combination with a ColorRamp.

This allows you to color each instance along this gradient.

This has the disadvantage that you don't use separate materials, but at the same time this could be an advantage.


(Blender 3.4+)

$\endgroup$
2
  • $\begingroup$ Thanks for this, I can't wait to try it out ;) $\endgroup$ Commented Nov 28, 2022 at 17:25
  • $\begingroup$ @glen_candle You are welcome! $\endgroup$
    – quellenform
    Commented Nov 28, 2022 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .