Page MenuHome

Fix T93455: Set material node does not use empty slot
Changes PlannedPublic

Authored by Hans Goudey (HooglyBoogly) on Jan 20 2022, 10:47 PM.

Details

Summary

In T93455, the set material node added a new material index to mesh
primitives created in the node tree, since it did not find the material
it assigned in the material list. It would be better to reuse the first
empty material slot when possible, for a few reasons:

  • The default material index will use the material, which is useful for modifiers like remesh that don't interpolate attributes.
  • We could potentially avoid storing material indices if they were all zero and we stored them outside of MPoly in the future.
  • It's expected intuitive behavior anyway.

Diff Detail

Event Timeline

Wouldn't you have to make sure that no polygon is using that empty material slot?

Hmm, yikes, true. Maybe that would be prohibitively expensive. Especially in the worst case when you have 16 thousand empty material slots each used by a single polygon, except for the last one.

It still feels like there should be some way to get that behavior though.

On the other hand, maybe it's better to think of this as a consequence of the way we add an empty material slot to all meshes created in geometry nodes-- a hack to fix another (less important IMO) issue.

Hans Goudey (HooglyBoogly) planned changes to this revision.Apr 28 2022, 1:46 AM

I think the proper way to do this is to move the material_index attribute out of MPoly. Then the easy way to check if material indices have been set yet is to check whether the attribute exists.

That's basically just part of T95967.