7
$\begingroup$

I'm trying to set a different existing material on 5 Instances made with Instance on Points. Trying both 3.0.1 and 3.1 to no avail.

Is there any value or attribute that signifies which instance you are on?

I want to build a setup for texture painting with 5 copies of a character and therefore I am linking a rigify rig with the meshes that gets instanced. That seems to make it trickier if not impossible to do custom attributes. Either want to change material for each copied instance or have some way to swap textures in a shader graph. As long as you can paint a different texture on each copy.

I've tried these three answers to similar issue without results: Set material for instances problem (Blender 3.0),
Control Instance Color with Geometry Nodes,
How to assign a different material color to each geometry nodes instance

$\endgroup$

4 Answers 4

5
$\begingroup$

After a bit of faffing around, I've so far established that the Set Material Index node will work only if the incoming geometry, with materials assigned to slots, is on the same branch. The materials do not have to be assigned to faces of the incoming geometry... it just has to have its slots filled.

In this example, the incoming geometry is just a plane, with 4 material slots.

enter image description here

Cubes instanced on a line have their instance indices stashed, before Realize Instance wipes them.

A function of the stashed indices is used to Set Material Index, while the (material-slot-bearing) incoming geometry is on the same branch.

The incoming geometry has been tagged, so can be selectively deleted before output.

enter image description here

The GN-generated cubes are now assigned the separate materials, per-instance, as expected.

$\endgroup$
2
  • $\begingroup$ Thank you for this! Trying to replicate my own answer suddenly didn't work today, but your solution did! $\endgroup$
    – bastian
    May 16, 2022 at 16:57
  • $\begingroup$ This has been the hardest thing for me to figure out so far using Geometry Nodes. The modulo trick made sense but it never worked, until I realized I wasn't using "Instance" in the Capture Attribute panel. Thank you for this! $\endgroup$ Jun 20, 2022 at 19:29
3
$\begingroup$

STORE NAMED ATTRIBUTE for points with value as ID before INSTANCE ON POINTS, then NAMED ATTRIBUTE integer using the same name from the STORED NAMED ATTRIBUTE on the ID for the selection on a RANDOM VALUE using boolean enter image description here

$\endgroup$
2
$\begingroup$

Managed to figure it out with inspiration from this answer:How to access geonode generated "instance ID" from Cycles material?

My node setup looks like below and assigns materials all in geometry nodes: Node Graph Character

$\endgroup$
1
$\begingroup$

This post is a bit older, but I just got to the same problem.

There is a workaround to still transfer material indeces (and have that material actually show) to geometry which is generated in the node tree:

You simply need to join some face of your input geometry with the particular material assigned to it with your new geometry before assigning the material index. You can delete that face again afterwards and the material transfer will hold. I stored a boolean "delete" before joining on that face. Makes it easier to delete all face snippets at once should you need to transfer multiple materials.

$\endgroup$

You must log in to answer this question.

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