Maya is old enough to have a few of those chronic pains, and I just ran in to one which -- once we debugged it and figured it out -- I realized has been a constant irritant for at least the last decade and if my creaky old memory does not lie was a distinct pain in the butt as long ago as 2002. In another context I might even have been able to diagnose it but instead we spent a ton of time and energy working around an unexpected behavior which is, in fact, purely standard Maya. It's stupid Maya, but it's standard too. Maya, alas, is double plus ungood about mixing per-face and per-object material assignments. So, I figured I'd document this here for future sufferers: it might not ease the pain much, but at least you'll know you're not crazy.
The basic problem is that assigning materials to faces and to objects use slightly different mechanisms. If you check your hypergraph you'll see that per-face assignments connect to their shadingGroup nodes through the
compInstObjectGroupsattribute while object-level assigmemts go through the similar-but-not-identical
instObjectGroupsattribute (if you're looking for these in the docs, the component cone is inherited from the
geometryShapeclass and the object version comes from
As long as you're working with one object at a time this isn't a problem. However, if you're duplicating or copy-pasting nodes, there's a gotcha: If you ever try to merge meshes which have a mix of per-face and per-object assignments, Maya will magically "remember" old per-face assigments in the combined mesh. If you're a masochist, here's the repro:
- create a object, give it a couple of different materials on different faces
- duplicate it a couple of times
- assign a per-object material to the duplicates, overriding the original per-face assignments
- combine all the meshes.
- Et voîla! The cloned meshes revert to their original assignments
compInstObjectGroupsconnections are driven by hidden
groupIDnodes which don't get deleted when the per-face assignments are overridden by the per-object ones in step (3) . They stick around even though they aren't being used, and when the mesh is combined they step right back into their original roles.
If you're doing this interactively it's an annoyance. If you're got tools that do things like auto-combine meshes to cut down on transform load in your game.... well, it's a source of some surprising bugs and equally surprising bursts of profanity. But at least it'ss predictable.