Home Technical Talk

[Maya] Duplicated objects losing material connections

Using Maya 2016.5 sp1 on win 7 x64

We have some models we bought that I'm now using for kitbashing for level design. Some of the meshes are somehow dirty and losing material connections when I duplicate them. I've tried every trick in the book for cleaning these, short of remodeling them myself. I am trying to avoid completely reassigning materials, some meshes are a little tricky selection-wise and also involve many materials.

It seems to work a little erratically, the only solid lead I have right now is that I can import fresh as obj or fbx. Then delete faces to trim down to what I want, save and reload the file. From here, any time I duplicate, it loses one or more connection to a shading group and attaches that connection to another material that was also assigned. Further duplicates continue until there's only one material left, holding all the face sets. Loading the scene is where the problem starts, since nothing appears to happen out of the ordninary until the scene is loaded and duplicates are made.

I can't replicate the problem with anything but this set of meshes, but if anyone has any insight, I'd be very grateful!

Late edit: I found a simple test case here, but it doesn't show the multiple material connections here. The two hypergraph windows show the two trimmed meshes, not the original at the bottom. I've only deleted the single center face.


Replies

  • throttlekitty
    Options
    Offline / Send Message
    So the question came up about any custom stuff or plugins I may be running, so I reverted back to a default configuration. I also discovered that I can recreate this on a maya-created plane. Here, I've started with a plane, assigned a blinn to each face. Then duplicated and deleted one of each face. Saved/loaded, then duplicated that set to the top row. Poof. I don't even know what to think now.


  • TTools
    Options
    Offline / Send Message
    TTools polycounter lvl 4
    Interesting.  So I just tried replicating your test in an empty Maya scene. I created 4 blinns and a plane.  I assigned each blinn to face on the plane, then duplicated 4 times.  I then manually deleted all the faces with one of the blinn assignments per duplicate as you show in your test.  I then saved the scene, and immediately opened the scene back up.  I selected the planes with faces removed and duplicated to the topmost row.  Material assignments look as they should.

    A couple things to check/try:
    How often have you Deleted All History for the scene, and how frequently do you Optimize Scene Size?
    Is there any chance that your duplicates are instances?
    Have you tried the "combine with a cube" trick?  Sometimes when we get wonky things from vendors, simply combining their object with a cube will force maya to rebuild the shapenode and re-establish shader face assignments. (Vertex reordering and face numbering gets updated as a product of combining because the number of faces/vertices has been modified, so previous numbering gets rebuilt)

    Also, if you have a simple scene like this that you can replicate, would you mind sending it to me so I can dig a bit deeper?

  • throttlekitty
    Options
    Offline / Send Message
    I can't find this old scene, I'll have to revisit this over the weekend when I have time. I'm a little obsessive over working clean, I most likely cleared history when doing this test since I was trying to isolate the materials problem. I did try recreating the issue briefly the other day in response to your post in the tech artists thread and couldn't. So maybe it's fixed in 2018? It was something I went around the changelogs since 2016.5 looking for but haven't seen anything that stands out.

    I just bought your TTools set and haven't tried it yet. But what I've since discovered was using detachSeparate as a bandage for when this happens. What I'd do while kitbashing or whatever is select the bad faces, separate them off into a new object, assign the material at object level, then combine it back with the original model. And yeah, this is usually when I'm working on working kitbashes or prepping vendor models.

    In these instances, the cube trick wouldn't work- Either a bad assignment directly from an OBJ or somewhere through steps working a model in maya give multiple empty instObjGroups from the shading engine to the geometry. Once this happens, each time the object is duplicated, another empty group connection gets added until eventually it breaks. With the usual cube trick, Maya never seemed to evaluate the empty groups during the combine- or at least to my liking since the groups always made it through in their original form.


  • TTools
    Options
    Offline / Send Message
    TTools polycounter lvl 4
    Very very interesting...man, without a test case that's going to be a hard nut to crack.  Do you happen to know the source application that your vendors are using?  That might give some insight. 

     I wonder if you'd also see this with FBX vs obj...though an obj with mtl counterpart is really about as basic as it gets.

      You mentioned clearing history, but not File>OptimizeSceneSize to clean redundant shading network connections.  I'm assuming  you've also tried that, but I don't want to assume anything.  Optimize Scene Size option box also has some additional options not enabled by default that perform some even more aggressive cleanup functions.

    Sounds like we might have to wait until you run into another case.  When you do, please shoot that file to me.  I'd definitely love to take a crack at it!
  • throttlekitty
    Options
    Offline / Send Message
    Hey @TTools are you sure the optimize routine works that way? I double checked the documentation and I only see the ability to collapse duplicate shading groups into a single one- which I've never seen work anyway but maybe it's a very specific situation that it fixes.

    Ok I found it in a bad place, lol. I usually keep these different "junk" files of different types for testing quick exports or whatever in a hurry. It's looking fixed in 2018 at least- I accidentally saved over junk3 there. But, if you open junk2 in 2016.5, and duplicate everything you should see something like this. In 2018, everything duplicates without issue, which is awesome.



    I've seen no difference in obj, fbx, or things that were purely made in maya. I haven't done any serious environment or kitbashing work since upgrading so I guess I'll keep an eye out for it should it happen.
  • TTools
    Options
    Offline / Send Message
    TTools polycounter lvl 4
    @throttlekitty
    I've found that under the hood OptimizeSceneSize has some very interesting code in it for checking and removing superfluous nodes. This gets some "hand waving" in the documentation, but the associated MEL script called by OptimizeSceneSize tells a different story.  Check out "C:\Program Files\Autodesk\'YourMayaVersion'\scripts\startup\cleanUpScene.mel".  You'll find several cases throughout the code where a listConnections is performed to determine and remove unused "hanging" nodes.  Look around lines 2060-2085. I've pulled code from this script a number of times and integrated for my own applications so I could streamline cleanup prior to executing complex combine or extraction processes.
    I downloaded your 7zip file and will take a look in the next couple of days.  Glad to hear that it's been resolved with 2018, but is sure would be nice to finally know the root cause.  I'll see what I come up with...but I'm making no promises! lol.  :D
  • TTools
    Options
    Offline / Send Message
    TTools polycounter lvl 4
    So I just ran some quick tests in Maya2016LT. (It's what I have available to me on my  laptop).  The bad news is that I could not replicate what you are seeing.  No matter how many times I duplicate all objects in the scene, groups of them, or individuals, they all retain their correct shader assignments.

    Some items of interest though.
    Upon scene load I incurred warnings for missing nodes:
    poseInterpolatorManager
    shapeEditorManager
    Those may be involved...or maybe not.  When I am able to access my desktop I'll be able to test the files in 2016.5 proper.

    I thought I would share a couple of screenshots to demonstrate what I was referring to regarding OptimizeSceneSize removing hanging nodes.

    Here is one of your objects after having performed a default Maya Separate (which for the record, I don't ever recommend doing!) AND a Delete History By Type.  Note all of the ghosted polysurface shape nodes that were not removed by deletion of history.  These extraneous nodes can end up wrecking havoc the deeper down the rabbit hole you go.


    Now check out the same object after Optimizing Scene size.  Clean as a whistle.


    For your convenience, there is a TTool called Nuke that will delete scene history and optimize scene size in one shot.  Look for it on your TTools shelf per this icon:

    If you are not rigging and don't need scene history, I highly recommend running this prior to every save.  It will make your files much more stable, and smaller in footprint.
    As I mentioned earlier, I will keep banging on the file you provided.  In the meantime, you might see if you can ascertain the source of the two missing nodes I mentioned above.  They might be native to 2016.5 and not 2016LT, but if they are not, they could also be getting pulled in via a plugin or 3rd party script.  Perhaps your vendor is using a 3rd party plugin or script that is generating these nodes.
    I'll be in touch.
  • throttlekitty
    Options
    Offline / Send Message
    Hey, thanks for looking! I'm less concerned about this now that I've more or less confirmed that I won't have issues in 2018. Thanks for the tip on your Nuke script. What about the cleanPerFaceAssignment plugin, I'm not sure if LT has it or if you load that one. I recall testing with that off and on and not seeing any difference in behavior, and also wondering exactly what that thing does, so I just leave it as an auto load.

    Those nodes might not be available in LT, they are from vanilla plugins for authoring blend shapes and pose corrections. AFAIK they get created as empty nodes on a new scene and should be harmless. Either way, I hate micromanaging plugins and I need that one!

    This scene is something I had made for testing this material issue, so there's no external forces at work here. Though at this point I've forgotten the steps that I took the models through, I'll guess that a boolean was involved
Sign In or Register to comment.