Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Export2Maya - Export Unity Scene to Maya Scene File

Discussion in 'Works In Progress - Archive' started by Fishypants, Mar 20, 2014.

Thread Status:
Not open for further replies.
  1. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Hey everyone! Figured I would share what I'm currently working on. So I recently found the need to export Mesh gameobjects in a Unity scene to Maya. Most importantly I needed the vertex colors to carry across as well. Problem is the OBJ file format doesn't allow a way to include vertex color information.

    I was thinking of making a custom OBJ format, and the appropriate C++ Maya plugin to read the data, but this seemed like overkill. Not impossible, but a lot more work and a lot more setup time to use.

    So I thought, why not write directly to the Maya file format? It has been a long, headache filled journey but it is just about done! A lot of care has been taken to ensure that once you export the Maya scene out of Unity, then import it back into Unity, that everything lines up correctly in the same spot.

    This tool is useful if you want to build accurate collision geo based on the positions of objects in your scene, or if you wanted to generate terrains in Unity then write them out for use in Maya, or if you wanted to export your scene and bake lightmaps with Vray or Mental Ray.
    $Example-Images_01.jpg

    What I have exporting so far:
    Vertices
    Normals
    Edges
    UVs
    Lightmap UVs (with correct Tiling and Offset)
    Vertex Colors


    I will update this thread as more features are added.
     
    Last edited: Apr 16, 2014
    milan8888 likes this.
  2. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Did a major overhaul last night. Was running into memory issues when dealing with large complex scene exports. The memory usage is now stable and stays consistent. Changed the way the files are written and got an increased operation time that is about 3 times faster now. Only thing left is to gracefully handle name clashes in Maya.
     
  3. effectzero

    effectzero

    Joined:
    Dec 20, 2012
    Posts:
    5
    God Bless you!! Exporting the lightmap UVs is a huge bonus. Any plans on exporting shaders as well (With component shading intact)? Even if its generating a phong with connections to the diffuse and normal maps it would be a tremendous help for my workflow.
    How can i get my hands on this pot of gold? I'd absolutely provide any and all feedback i can and will definitely put it through some light and heavy lifting.
     
  4. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @ EffectZero:
    I was planning on it exporting shaders, the only questionable thing would be if people do not adhere to the Unity way of naming attributes on their shaders, it could be close to impossible to hook the textures up correctly. For example if the shader uses _MainTex (and most shaders usually do) then you could obviously plug that directly into the color channel of whatever shader you decide to default to in Maya (blinn, phong, lambert). But if people use their own naming scheme then it would be a headache / impossible to figure out where it needs to go.

    At the absolute very least, it should be possible to just assign the materials, even if it cant hook up textures in Maya.

    I will be releasing the exporter soon, by the way. Deciding if I want to put it on the asset store or not (it's taken a while to write this lol). If I do I would love a few beta testers :D
     
  5. popMark

    popMark

    Joined:
    Apr 14, 2013
    Posts:
    114
    This sounds amazing! Any sooner to a release? I have a project on the go that now needs renders of the scene and this would save a massive amount of time. Will it work with instances?
     
  6. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @popMark -

    Almost there, the biggest hurdle that I'm working on at the moment is name clashing in Maya. In Unity it is perfectly acceptable to have multiple objects named the same, but in Maya you cant do that unless the objects are parented under other objects that are uniquely named. At that point Maya uses the object path to resolve the name clash. If you have your Unity scene setup and all the objects are uniquely named, then there will be no problems but in the event of name clashing I need to rename the objects as they are written to the Maya scene file. I was really hoping that Maya would be smart and auto-magically rename the objects itself on file load, but it doesn't appear to be the case.

    Instances should theoretically be easily supported. I'll look into it, but my initial guess would be that supporting instanced objects should be fine.
     
  7. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    Would be really stoked for this. Keep us Updated
     
  8. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @ prestonplatt -

    Sure thing! Believe me, once I release it, you'll know :p

    At the moment I was working on resolving name clashes in Maya. Its 99% there, but I discovered a sort of bug last night that I am ironing out at the moment. Once that's fixed I'm going to implement shaders and material assignments, so your objects are exported with materials and hopefully textures intact as well. When those are both done I'll release a version of it.
     
  9. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    @Fishypants that sounds beautiful. the difference in material build structure i'm sure is a bitch but if you could get those textures to transfer over even very simply that would be awesome. But even blank materials with the geometry association would still be so useful. You freaking rule.
     
  10. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Ok, so this past weekend was dedicated to bug squashing and implementing name clashing checks. This was actually really tricky. What appeared to be 1 bug was actually about 5. Got it all working though. After testing the exporter on my own scene I switched over to testing it on the Angry Bots scene, as its more complicated and was a better stress test for the exporter. FINALLY got it to export correctly with hierarchies and name clash checking in place. YAY! :D

    Now its time to implement shaders and textures! Stay tuned.
    $Export2Maya_hierachies.jpg
     
    Last edited: Apr 1, 2014
  11. Dave1005

    Dave1005

    Joined:
    Jun 19, 2013
    Posts:
    1
    This is really looking great!! Can't wait to see how it turns out!
     
  12. cg_destro

    cg_destro

    Joined:
    Aug 13, 2013
    Posts:
    142
    looking gooood! :)

    would be great if we could move, scale, rotate, and duplicate prefabs in maya and import in unity that changes and camera animation, almost like we could design level in maya :) but not sure if it possible :p

    good job! :)
     
  13. Xyke

    Xyke

    Joined:
    Feb 28, 2013
    Posts:
    1
    Hey Fishypants,
    what a powerful tool u made here :) Is there a way to test it right now or do u have already submit it to the asset store ?

    Good job BTW :)
     
  14. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @Dave1005 - Thanks! :D

    @cg_destro - Thanks! Going from Unity to Maya is somewhat easy but going from Maya to Unity is trickier. Only because Unity has its way of dealing with imported assets. I think exporting to FBX is probably your best bet at the moment, but I agree, it would be nice to design everything in Maya and keep all the instanced objects in place. I really wanted something like this when I started using Unity but I kind of got used to just doing things the "Unity Way" of importing everything as FBX and placing the objects inside Unity. It's not impossible to create a link between Maya and Unity, so changes in Maya get reflected inside the Unity editor, but it is definitely more involved.

    @Xyke - I haven't submitted it to the asset store yet, but as soon as I wrap up the shader export I will submit it. It's almost there, very very close :D
     
  15. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Got preliminary material export working! Supports both per object and per face assignments. Now to just have it copy the textures themselves and hook them up :D
    $Export2Maya_materials.jpg
     
    Last edited: Apr 8, 2014
  16. taichiu727magnus

    taichiu727magnus

    Joined:
    Sep 16, 2013
    Posts:
    144
    nice, keep up the good work
     
  17. Thomas-Pasieka

    Thomas-Pasieka

    Joined:
    Sep 19, 2005
    Posts:
    2,174
    That's indeed pretty cool. Does this work with Maya LT as well?
     
  18. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @ Thomas - Hmmm, it should, I don't see why not. I'll have to look at how Maya writes out the scene file for the LT version. I wouldn't imagine it is too different from the standard Maya file. Did a quick search and found this on the Autodesk site:

    I will download LT just to double check but it should work fine.
     
  19. Psychon

    Psychon

    Joined:
    Mar 11, 2014
    Posts:
    17
    Wow Fishypants this is pretty much exactly what I was looking for, except that it's not out yet :). I hope you'll be releasing soon! I noticed in a previous comment you mentioning that it would be much harder to go from Maya to Unity. What about having a custom mass FBX exporter on the Maya side that tracked the original file location of fbx files. That way when you finished editing the exported scene in Maya you could mass export out all the objects to their respective FBX files.

    Ideally you could make your own reference system to bypass Maya's crap instances/reference editor. The references would be linked to the fbx files and you could lock/unlock a reference for edit from within the scene but that's a whole different tool in itself and I'm getting ahead of myself. Looking forward to the release.
     
  20. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    And finally got preliminary texture export working! There's one last bug that I am fixing at the moment. Almost there . . .
    $Export2Maya_textures.jpg
     
  21. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    pretty cool, nice work.

    i believe you can create custom attributes in maya to store whatever structures you need (i'm fairly sure at least)...so you may be able to 'tag' prefabs and somehow roll them as references or instances (no clue how that might work). i was looking at handling instancing with tagging the models with a particular locator nomenclature (basically building a point cloud of transforms for export) and a script in unity to handle prefabs... perhaps this would be an approach for your round-about workflow.
     
  22. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Woo Hoo! Fixed the last texture export bug. Just need to clean up a few things and I will submit it to the asset store. Here's a few frames of me having some fun with Vray in the Angry Bots scene:
    $Export2Maya_vray_01.jpg $Export2Maya_vray_02.jpg $Export2Maya_vray_03.jpg
     
    Last edited: Apr 13, 2014
  23. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    Awesome! is it in the store?????
     
  24. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @prestonplatt - Just about, I have everything setup and almost ready to submit. Just finalizing the documentation at the moment. Looking to submit it tonight.
     
  25. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    so fun seeing you throw the scene and V-ray and do a simple render and get those results. An absolutely awesome base working spot. cannot wait to buy!
     
  26. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    And .... submitted! Now just have to wait and see if it is approved ...
     
  27. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Great work!!!
     
  28. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @ devang_xprt - Thanks! :D
     
  29. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    Already bought and love it. You did an amazing job.
     
  30. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @prestonplatt - Hey! Glad it is working out for you. To be honest I didn't even know it was live until you responded to this thread. Lol. Anyways if you run into any bugs or have any feature suggestions please let me know and I will update it accordingly.
     
  31. prestonplatt

    prestonplatt

    Joined:
    Mar 28, 2014
    Posts:
    9
    @Fishypants thanks that sounds great. Already been playing around. With so many assets in Unity its fun to have them now in maya even at the game LOD. The one thing I would push is the terrain that you spoke of maybe implementing. This might be a super noob question but my expertise is in Maya. Is there any way to break the terrain feature (Example bushes, trees grass) into objects and a texture map for the ground plane?
     
    Last edited: Apr 22, 2014
  32. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @prestonplatt - as far as the terrain is concerned, I will need to look into it deeper to see what data can be extracted from it. I remember reading up on it before and I remember there was no "easy" way to get at the data from inside Unity. Although things may have changed since then, but even if that is the case there are work arounds. Terrains are next on the list, as I feel they will be easier to implement, plus quicker to get results than skinned meshes, and it will be nice to have regular updates with the tool. I like regular updates, they make me happy :D
     
  33. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @prestonplatt - Just quickly looking through the docs there is a lot more information than I expected about the terrain data. Granted you can't query the vertices directly, but you can infer what the vertex positions are based on the resolution of the terrain + the heightmap values. Which is basically the way Unity generates the terrain in the first place I'm assuming. All in all, terrains are next :)
     
    Last edited: Apr 23, 2014
  34. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Oh by the way, I have created an official Asset Store page for the exporter here:
    Export2Maya - Asset Store

    I will be using that as the main discussion page for bug reports / updates.
     
  35. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Been working on getting the lightmap workflow working with Export2Maya. Right now, it finds what lightmap index each object is assigned to, and creates a display layer inside Maya for easy selection and baking. Testing out generating lightmaps inside Maya using Vray. So far the results are working pretty well. Need to tweak a couple things as you can see a few objects didn't get mapped correctly, but it has to do with how the objects are assigned to the layers. I will get this fixed then push out a new version of Export2Maya.

    Screenshots! These were taken inside Unity, and all the lightmaps were generated inside Maya using Vray:
    $export2maya-lightmaps-vray_01.jpg
    $export2maya-lightmaps-vray_02.jpg
     
  36. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Alright, got the lightmap quirk fixed. Also wrote an accompanying MEL script for use inside Maya that will convert your exported scene into a lightmap-ready bake scene. Haven't run into any issues yet, so I will add the Lightmap Baking Workflow to the Export2Maya documentation and upload the new version.

    Some more screens! I was impressed with how well Vray handled the Angry Bots scene. There is only 1 directional sun light and 1 sky light, the rest of the lighting is coming from the emissive materials.
    $export2maya-lightmaps-vray_03.jpg
    $export2maya-lightmaps-vray_04.jpg
    $export2maya-lightmaps-vray_05.jpg
    $export2maya-lightmaps-vray_06.jpg
    $export2maya-lightmaps-vray_07.jpg
     
  37. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Ver 1.0.1 is Released. Small update but includes the following:

    Display Layer Creation - Display layers will be created for each lightmap texture in your Unity scene, and all the objects that use that lightmap texture will be linked to the display layer. This makes it easy to select and combine objects that all belong to the same lightmap texture.

    Export2Maya.mel - Maya MEL script that will combine all the objects in your Maya scene for you based on the display layers it finds. Basically open your Maya file and run it and you will have a couple objects ready to bake lightmap textures to.
     
  38. maart

    maart

    Joined:
    Aug 3, 2010
    Posts:
    82
    Any chance we will get to see an Export2Max plugin?
     
  39. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Hi Fishypants,
    I was wondering have you made it work with MayaLT because i am building a prototype level (sooner or later, more levels!) at the moment and i would like to export my scene into MayaLT since i have the full version of MayaLT and i cannot afford the full version of Maya at the moment so i am hoping that your asset can be a life saver... i just remembered that you wrote something in quotation which mentioned importing Maya files, but does that also mean that i don't have to own any version of Maya (not LT of course) in order to export my scene so i can read it with MayaLT??? thanks for your time.
     
  40. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @maart - Hmmm I doubt it. First of all, I know Max decently, but it is not my 3D program of choice, so my familiarity of it isn't as great as Maya. If there is an Ascii version of their scene file then it could be possible. I found this information and it is a bit discouraging: http://wiki.cgsociety.org/index.php/3ds_Max_File_Formats

    specifically:
    3ds Max saves scenes to a proprietary binary format with the extension .MAX. The specification of the format is not public. The content of the file is heavily dependent on the plug-in data used to build the scene, thus parsing the file outside of 3ds Max makes little sense (although certain data fragments can be extracted).

    Not sure how old that information is, but it sounds like the Max file format is a secret for the most part.

    @ davem250 - I haven't personally tried it with MayaLT, although I have heard from a few users that it works ok. The only issue you would run into is if you are looking to create lightmaps in Maya with the data Export2Maya exports. It's not impossible, but you wont be able to use the accompanying Export2Maya.mel script as I heard MayaLT doesn't support custom scripts. (It helps set the scene up for you for lightmap generation) Although I guess the Subscription version of Maya LT supports Mel scripts. I'm not too sure about the compatibility of Mel scripts when it comes to the different versions of Maya and what Autodesk supports. It changes all the time. But if you are looking to export geometry and materials and textures then it should work ok on MayaLT.
     
  41. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Alright that is very good news because what i basically need Export2Maya for is simply to import a Unity scene with a lot of base meshes like Cubes and all that i really don't need to create lightmaps so if i have understood you correctly then for the base meshes (no colorful material assigned to any of them! only grey colored material and white colored material!) that should work just fine? if so then i will instantly buy this asset when i get my pension (end of june!)
     
  42. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @davem250 - Yes it should work fine. If you would like I can install MayaLT to try it out and confirm for you.
     
  43. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    That would be nice if you would do that :) also i don't know if this is a MayaLT function or what i should call it but i can import .mel files (though the only one i have as experiment file is workspace.mel) and at the bottom of the MayaLT window there is an MEL command line thingy (i honestly don't know much about Maya so it's more of a guess work :p) but yes that would be awesome if you would that :D
     
  44. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Hi i have to report back that so far i can see no errors when using .mel scripts.
    I have just downloaded and installed XROMM tools 2.1.0 which i found for free and when clicking on any of the buttons they react and the shelf is there also so i'm guessing that you can use .mel scripts but please if i am utterly wrong please say it because i am not entirely sure that i am correct :) thanks for listening :D
     
  45. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    @davem250 - do you have the subscription version of MayaLT or the non-subscription version?
     
  46. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Non subscription :)
     
  47. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    Hmmm, non-subscription shouldn't allow MEL script usage, unless something changed recently. I'll dig into it tonight when i get home to check out MayaLT and report back what I find.
     
  48. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    Ok but just for info i'm using the full paid version with sp1 i don't know if that is it? ooh and it is 2015 version!
     
  49. Fishypants

    Fishypants

    Joined:
    Jan 25, 2009
    Posts:
    444
    I tried to install trial version of Maya LT, but the installer kept erroring out saying there was a network problem maintaining a connection to the Autodesk servers. I will try again later.
     
  50. davem250

    davem250

    Joined:
    May 28, 2013
    Posts:
    186
    That sounds odd, but then again if there is a heavy traffic on their servers then i guess it's quite normal :) (Not meant as some kind of sarcasm or criticism! this is purely speculation :))
     
    Last edited: Jun 25, 2014
Thread Status:
Not open for further replies.