Home Unreal Engine

Material ID order from Maya?

quad damage
Offline / Send Message
Joopson quad damage
Hi all!

Been pulling my hair out over this. For the game I'm working on, we need all the characters to have 3 material slots, in a particular order. Hair/skin, Upper Body, and Lower Body.

I can't seem to get them to load in any particular order, with any rhyme or reason. I'm assigning materials in Maya and exporting as an fbx.

I've tried assigning in the order I want, and renaming materials to alphabetically go in the right order, but that doesn't seem to do it.

In the documentation, it mentions appending skin0# to the materials (showing a max screenshot with the names as such), to set the order. So _skin00 _skin01 _skin02 et cetera. But this doesn't affect anything either, while exporting from Maya.

These are rigged meshes, so I can't mess with the meshes themselves. Any idea what I need to do to solve this?

Thanks!

Replies

  • m4dcow
    Offline / Send Message
    m4dcow interpolator
    I just tested out the _skin## naming scheme and it worked for me.

    I thought it might have to do with a mesh keeping its order once imported but made a mesh without _skin## assignments, imported it the material ids order were random, and then edited the mesh in Maya with the _skin## suffixes and reimported, with the order changing as expected.

    Try exporting your fbx file as ascii, and making sure the materials are named what they should be in the actual exported file ie: with the _skin## appended (I used notepad++). Each material name shows up in 2 places for me in my simple file, that might be different for something rigged and skinned. I was able to rename _skin00 to _skin01 and vice versa and have that switch material order when I re-imported the file to UE4.

    I also tried to re-order a file without the _skin## suffixes, to see if the material order changed, which didn't work, so the importer obviously uses something different to order the material ids than the order in which it parses them.
  • tharle
    Offline / Send Message
    tharle polycounter lvl 9
    make sure the names of the materials are identical too - mat_skin00, mat_skin01 etc. if you try and call them names that also contain numbers or _ characters then have _skin00 after it can get confused.
  • Joopson
    Offline / Send Message
    Joopson quad damage
    Thanks for the help guys; weirdly enough, the _skin0# suffix works for every other mesh I've tried it on, besides the skeletal meshes I'm trying to work with. Not really sure why, but I talked with the programmer about it, and he's willing to work around the material ID order, so, it's not a problem for me anymore.
  • tharle
    Offline / Send Message
    tharle polycounter lvl 9
    you may have just had the order of the naming wrong - i think the skin## but has to be last.

    that said things like numbers and _ characters probably mess up where the importer is looking for key words like "skin##" so keeping it as simple as possible is probably best
  • antweiler
    Offline / Send Message
    antweiler polycounter lvl 8
    Here is how i "solved" the problem, after the material naming approach failed.
    I separated the mesh by its materials, so one material per mesh (each mat is a drawcall anyways). I have the meshes in the top hierarchy of my maya scene, and the order in which they are in the outliner is the order the materials are imported into UE4. Why this is, i dont know.
    Maybe not enough peoples are having this problem, but its a pain when you have teammembers using Max. Epic should drop the archaic concept of material IDs, and implement a system, where materials are indexed by their names, instead of order.
  • tepelkon
    Hi, I got the list of faces and materials per face in order with this code:
    import maya.cmds as cmds

    #Obj to be iterated
    obj = cmds.ls("nameoftheobject")
    #Get number of faces total
    allFaces = cmds.polyEvaluate(objs,f=True)


    for faces in obj:
        print faces
        for face in range(allFaces):
            print face
            iteFace = faces+".f["+str(face)+"]"
            cmds.select(iteFace)
            cmds.hyperShade(smn=True)
            print cmds.ls(sl=True)

    Its still missing the the array and filtering but the order of the material coming from that iteration should be the same as in fbx export file?
Sign In or Register to comment.