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
compInstObjectGroups[]
attribute while object-level assigmemts go through the similar-but-not-identical instObjectGroups
attribute (if you're looking for these in the docs, the component cone is inherited from the geometryShape
class and the object version comes from dagNode
).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
What appears to happen is that those
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.
compInstObjectGroups
connections are driven by hidden groupID
nodes 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.
The workaround: Before doing any mesh combination, delete the history and something harmless to this history of the meshes you're about to combine. (I use a triangulate step, since this happens only at export time) . That kills the rogue <code>groupID</code> nodes and keeps the combined mesh looking the way you intended.
Sheesh. What a way to make a living.
No comments:
Post a Comment