2
$\begingroup$

I want to apply an existing material to an added geometry from the geometry nodes. This might seem an already answered issue but following different tutorials and browsing existing questions, I can't seem to make the 'classical' approach work. For example I tried How to get UV for the generated grid in geometry nodes? without success.

Here is my setup below with the UV map passed as attribute. It's very basic but whatever I do I can't get the right UV map in the shader. What am I doing wrong?

EDIT : I'm using Blender 3.6

UV map as atttribute

$\endgroup$
6
  • 1
    $\begingroup$ ...the node Set Material is missing. Without it, no material is assigned to the geometry created in Geometry Nodes. $\endgroup$
    – quellenform
    Commented Jul 27, 2023 at 13:16
  • $\begingroup$ It is already there. It's the Set Material Index that you can notice. $\endgroup$
    – Jag JB
    Commented Jul 27, 2023 at 13:43
  • 2
    $\begingroup$ There is a difference between Set Material and Set Material Index. When you create a new geometry with Geometry Nodes, no material is assigned yet and therefore you cannot set an index. ...or does the object itself already have one or more materials? $\endgroup$
    – quellenform
    Commented Jul 27, 2023 at 14:08
  • 1
    $\begingroup$ ...maybe helpful: blender.stackexchange.com/questions/279136 $\endgroup$
    – quellenform
    Commented Jul 27, 2023 at 14:11
  • $\begingroup$ Indeed, Set Material was the solution. That's actually very misleading if Set Material Index doesn't 'Set' anything but is only able to 'Pick' something preexistent. Thanks for your answer! $\endgroup$
    – Jag JB
    Commented Jul 27, 2023 at 16:14

1 Answer 1

3
$\begingroup$

"Join Geometry" works similarly¹ to object joining in regards to materials. After joining, all faces still point to the same material they pointed to before joining, but the material indices get updated to minimize the number of such indices. For example:

Mesh 1 Mesh 2 Result of Joining
0 red 0 no material 0 red
1 no material 1 yellow 1 no material
2 red 2 blue 2 yellow
3 yellow 3 blue

So first the materials from first mesh are added, then from the 2nd mesh, 3rd mesh, 4th mesh etc.

  1. Red
  2. Empty slot
  3. Red
  4. Yellow
  5. Empty slot
  6. Yellow
  7. Blue

Then for each material check if it is a duplicate (i.e. also exists earlier on the list) - if so, remap all faces using this material index to the index of the first occurrence of this material, remove this material slot and shift following material slot indices to the left:

  1. Red
  2. Empty slot
  3. Yellow
  4. Empty slot
  5. Yellow
  6. Blue

  1. Red
  2. Empty slot
  3. Yellow
  4. Yellow
  5. Blue

  1. Red
  2. Empty slot
  3. Yellow
  4. Blue

In your case you have a starting geometry with some material, and a new geometry without a material:

Mesh 1 Mesh 2
0 some material 0 empty slot

Then you set all faces of Mesh 2 to material slot 0, which is a no-op, because they were set to that by default. And finally you join:

Mesh 1 Mesh 2 Result of Joining
0 some material 0 empty slot 0 some material
1 empty slot

Upon joining, the faces of Mesh 2 have their material slot updated to 1, because without the update the material they point to (None) would change, which is not a desired behavior.

Keep in mind, setting the material index to 0 would work, if you did it after joining, by e.g. capturing a boolean attribute and using it as a selection.

¹ - the difference is object joining keeps repeated materials of the active object.

$\endgroup$

You must log in to answer this question.

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