Page MenuHome

Geometry Nodes primitive "material_index" issues
Closed, ArchivedPublic

Description

System Information
Operating system: Windows-8.1 64 Bits
Graphics card: NVIDIA GeForce GTX 1060 6GB/PCIe/SSE2 4.5.0 NVIDIA 466.47

Blender Version
Broken: 3.0.0 Alpha, branch: master, commit date: 2021-07-22 22:44, hash: fafd21b14c23
Worked: --

Short description of error

There are two issues with geometry created directly inside the nodes. The first could be by design, the second doesn't seem to be.

  1. Geometry created directly inside the nodes doesn't behave as expected. It's created with the attribute material_index of 0, while it'd more sense for it to be assigned to the first material slot of the object by default (which when it comes to the material_index attribute is 1 for some reason). The lack of a valid default index leads the generated geometry to have no material upon creation, unlike hand-modelled geometry, which is assigned the first material by default. This could be by design, but...
  1. Assigning a valid material_index to fully procedural geometry doesn't work. It only works when joined to the original geometry, even if the original geometry is nothing at all.

I've attached a test file with the following node tree. All objects have the same material, the ones on the right use the workaround 2 tree while just a material_index fill. The original mesh in top objects row is empty (has no vertices), the second row has a cube.


Exact steps for others to reproduce the error

  1. Create a primitive in Geometry Nodes.
  2. Add a material to the object.
  3. Assign a material_index attribute of 1 to the new geometry.

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Confirmed.Jul 26 2021, 4:18 PM

Reading the commit message from rBf41a753e7514: Geometry Nodes: new Material Assign node would make me think this is a bug:

This adds a new Material Assign node. It can be used to change the
material used by an existing mesh or to assign a material to a mesh
that has been generated from scratch.

CC @Jacques Lucke (JacquesLucke)

Reading the commit message from rBf41a753e7514: Geometry Nodes: new Material Assign node would make me think this is a bug:

This adds a new Material Assign node. It can be used to change the
material used by an existing mesh or to assign a material to a mesh
that has been generated from scratch.

CC @Jacques Lucke (JacquesLucke)

Sorry, I was reading this wrong (since this is writing directly to material_index instead of going through the node).
Still, I would confirm this (since the attribute seems to be there for primitives I would not know why it is not working?)

I don't see a bug here. I think there are two points of confusion:

  • The material_index 0 does reference the first material slot. You are right that internally in Blender there is a weird offset for historical reasons, but to my knowledge that shouldn't leak to users.
  • There is a difference between adding a material to a geometry and adding it to the object. In your example, you added to material to the original mesh in the material panel. However, since you then create a new mesh from scratch, that won't have the material. To give procedurally generated geometry materials you should use the Material Assign node or initialize the material slots on the object (instead of the geometry). Materials slots on the object will overwrite materials on the geometry.

I agree with Jacques' description above. I'll close this report.