Search Unity

Unity Fbx Exporter - Export Meshes, Skinned Meshes, Terrains and Textures

Discussion in 'Assets and Asset Store' started by UnLogick, Oct 2, 2016.

  1. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    I've recently read up on how the lightmapping works and it has come to my attention that the truth is a bit more complex.

    Unity uses UV2 (or uv1 if there is no uv2) combined with the lightmap scale and offset to calculate it's lightmap uv. It then looks at the lightmap index to make a look up into the actual lightmaps as part of it's lighting model. The FBX format does not support lightmaps in a similar fashion so while I could export the data, no importer would read it properly.

    I will add functionality to allow exporting the lightmap textures along with either the modified uv2 or a data file containing the offset and scale so that this information is available when importing the fbx.
     
  2. Iegor-Malovanyi

    Iegor-Malovanyi

    Joined:
    Aug 30, 2014
    Posts:
    4
    Thanks for the answer
    We're waiting for new release.
    It's not necessary to refund, I'll do few more purchases when new version with lightmaps supported will be published to prove you that we (users) really need this thing
     
  3. shiro271072772

    shiro271072772

    Joined:
    Apr 14, 2016
    Posts:
    2
    Hi !
    I wonder if this extension could also export bones(rig) in skinned meshes ?
    Thanks a lot !
     
  4. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Yes it exports the entire skinned mesh with the rig, it does not export the animations or different poses, only the "current" pose at the time of the export. I have a long term dream of adding animations as well but no immediate plan.
     
  5. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    Hello! Thank you very much for making this tool, it perfectly solves a niche problem I'm having.

    I am having one problem with it though, the alpha on the vertex colours doesn't seem to be coming out correctly (the RGB values are correct)

    If you look at the screenshot you can see a mesh that is draw twice. The eye on the right is the original and the eye on the left is the exported version. They are being drawn with a shader that draws the alpha value to grey-scale so where the image is white the alpha is one and where it's black the alpha is zero. You can see the original is mostly alpha 1 with a fade on the ends. The exported version's alpha seems to track the brightness of the colour of the original image for some reason (although it does exhibit some of the end-fade of the original).

    I'm not sure what's going on here, any ideas?

    THanks.
     

    Attached Files:

  6. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Glad to hear it, always great to know that people like it.

    I just dug into the native code and found this particular line of code.
    Code (CSharp):
    1. colorArray.Add(FbxColor(color[0], color[1], color[2], color[4]));
    If I were a smart man, I might come to the conclusion I've written a very trivial bug that discards the alpha and instead takes the red part of the next vertex. :oops:

    I'm already working on an update that I expect to release in the weekend. It includes the custom properties that @Lempereur wanted, I ended up doing both the callbacks that I suggested I would do, but also a couple of custom MonoBehaviours (FbxMeshCustomProperties, FbxTextureCustomProperties, etc)

    upload_2017-6-22_21-7-25.png

    In other words: You can expect a new release "soon(tm)"
     
    Last edited: Jun 22, 2017
    hopeful likes this.
  7. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    Perfect! Thanks UnLogick, great that you're so responsive.
     
  8. ColinNorthway

    ColinNorthway

    Joined:
    May 25, 2016
    Posts:
    3
    Hey, UnLogick, any update on this? We're very eager to get the new improved version!

    Colin
     
  9. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Unity Fbx Exporter 1.2 is live on the asset store.
    Asset Store: Unity Fbx Exporter

    Added Fbx Custom Properties
    Heads up to: @Lempereur
    • FbxMeshCustomProperties
    • FbxNodeCustomProperties
    • FbxSkinnedMeshCustomProperties
    • FbxMaterialCustomProperties
    • FbxTextureCustomProperties
    I added a very simple scene to show how to use Custom properties from script, but honestly I think the best approach is to use the Fbx___CustomProperties and add those directly on each GameObject where you want custom properties to be added.

    Fixed Alpha in Mesh Vertex Color
    Heads up to: @sarahnorthway and @ColinNorthway
     
    Last edited: Jul 16, 2017
  10. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    The future of the Unity Fbx Exporter

    There are a few features that I plan to add to the Fbx Exporter.
    • Export Glow/Emission textures
      Requested by Thor, dunno why I didn't think of this before, it should be quite trivial.
      Edit: Turned out it wasn't quite trivial, I'm back to the drawing board on how to achieve this, but I'll get it done.
    • Export Cameras
      Unity 2017.1 now imports Cameras so it makes sense to Export them.
      Edit: 2017.1 is out so I'm gonna look at this one "soon(tm)"
    • Export Lights
      Unity 2017.1 now imports Lights so it makes sense to Export them
      Edit: 2017.1 is out so I'm gonna look at this one "soon(tm)"
    • Linux support
      The primary reason for adding Linux support is that I expect this will also work on Mac
    • Exporting TPose (new)
      It would make exporting of Skinned Meshes a lot cleaner to export their T-Pose.
    There are a few features that I want to add but that I dare not promise
    • Export Animations
      Fbx uses a different coordinate system, and the order of axis is also different so I dare not make a promise for this one, but I'll certainly give it a try
    • Mac support
      I want to support mac but I don't have a mac, I'm hoping the linux .so native library will work on mac. Even if the linux version doesn't work on mac I do expect the actual code to be identical. (I would just need to link the mac fbx sdk instead of the linux fbx sdk)
    • Export Lightmap
      This is commonly requested so I want to do it. But my problem is that there is no standard way to handle lightmapping, so I'm not sure I can get third party tools to support this. If you know what format you want me to export this in please let me know.
    If you have any further suggestions or feature request please let me know.
     
    Last edited: Jul 27, 2017
  11. ghcannon

    ghcannon

    Joined:
    May 4, 2017
    Posts:
    2
    Hi there


    I’m trying to use your FBX Exporter for a project I have here


    I’ll get right to the chase:


    I have a scene with a cape that is in a ‘rest’ state, undeformed.

    The cape has all the Unity Cloth stuff setup so when I hit the editor run button it gets nicely deformed.
    It is at this point that I want to basically export only the deformed mesh of that cape to an FBX. Nothing more than the mesh.


    However whatever I do results in a completely empty FBX. The exporter doesn’t complain about anything. I use Unity 5.5.2f1
    If I just have a Mesh Renderer on the object instead, it exports just fine, but that’s certainly not what we need.


    I just bought the package with the sole intent to use it for this. Is that not supported at all? I was left with the impression that you do support exports from a skinned mesh renderer.


    Looking forward to your reply

    Thanks,
     
  12. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Eh, Cloth? Well... I suppose that is a variant of the Skinned Mesh Renderer o_O

    Damn why isn't that on my road map or feature list...

    No worries, I've worked with Cloth procedurally before. Took me a while but I got it sorted out now. I'm just gonna wrap up a new release. :cool:
     
    kenamis likes this.
  13. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Unity Fbx Exporter 1.2.1 is live on the asset store.
    Asset Store: Unity Fbx Exporter

    Added Cloth Export
    The cloth is exported in it's current deformed state. Cloth meta information is not saved into the fbx.
    Heads up to: @ghcannon
     
  14. ghcannon

    ghcannon

    Joined:
    May 4, 2017
    Posts:
    2
    Waw! Shouts out for the light speed turnaround here! I'll test it out in a couple days and get back to you

    Thanks a ton!
     
  15. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Well I do believe this was the fastest turn around time yet.

    I was chilling by the computer anyways and I knew it was relatively simple, it turned out to be just around 30 lines of code. I've played with cloth procedurally before on the UMA character customization so I knew the tricky part of how cloth worked, namely translating between cloth vertices and mesh vertices. So all I needed to figure out how to read the cloth.vertices, turned out they needed to be translated from cloth space to model space fairly trivial once I knew it.
     
    hopeful likes this.
  16. sillysandysue

    sillysandysue

    Joined:
    Jan 1, 2017
    Posts:
    2
    Does the exporter support mesh vertex colors?
     
  17. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    yes.
     
  18. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @UnLogick I tried to use the FBX Exporter with Megasplat and it seems t isn't compatible yet -maybe due to different packed texture modes?
    @ Jeremy-Borton About Voxeland support although textures don't automatically export yet I did get the exported FBX to at least show textures correctly if the UV is changed to Box mode aligning to X (used a program called iClone in this case)
    This might allow you to continue work in a external painting program for example 3DCoat if we can't get the splat exported and working with the Voxeland-generated UV scheme. The texture across all the chunks tile seamlessly as well.
     
  19. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    I've talked a bit with the author of Megasplat and the problem here is related to Voxeland not having uv coordinates, instead it uses world position/normal to power a triplanar shader and that doesn't work with my current texture extractor. I've come up with a way I could make this work but it's not trivial and it will take some time.
     
    Ascensi likes this.
  20. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Unity Fbx Exporter 1.3.0 is live on the asset store.
    Asset Store: Unity Fbx Exporter

    Improved Cloth Export
    Both SkinnedCloth and UnSkinnedCloth is now supported. SkinnedCloth is exported as a normal skinned mesh. UnSkinnedCloth is exported as a normal mesh. The cloth is exported in it's current deformed/simulated state. Cloth meta information is not saved into the fbx.

    Skinned Mesh TPose exporting
    That's right you can now export your models in their T-Pose rather than their current pose.
    For technical reasons this doesn't play well with cloth!

    Very Very experimental camera and light setup
    The angles are wrong and the intensity is wrong, but a lot of values have been added. Slowly moving in the right direction.
     
    Ascensi likes this.
  21. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    Thank you, sorry that you would have to go through the trouble of coming up with proprietary code for this to work but in the end I think you and more customers to come will find your tool essential in their pipeline.
     
  22. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Hey! I bought your exporter today for our project, but I'm having a problem.
    We're having tile-based environment meshes in our project that we've vertex painted for texture blending in our shader. Unfortunately that painter wasn't particularly great and destroyed our UV2 channel on bake, so we decided to export these painted meshes back to 3DS Max with your tool and manually fix the UVs there.
    However, for some reason the vertex color data comes in all wrong! I'm not seeing any settings for vertex data in your exporter, and as you can see from the screenshot attached there IS data being imported, it seems like it's just allocated on the wrong verts.
    VertColorIssue.png
     
  23. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Seems the issue doesn't stop there.
    I just tried to simply export the Unity mesh and reimported that without going through Max, and while the vertex data stays correct, I'm losing all my Material IDs now. Seems like your tool doesn't support multiple materials in single mesh export?
     
  24. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    This all looks very strange indeed, everything you mentioned should be supported so I'd like you to wrap it up in a unitypackage and send it to me so I can take a look at what goes wrong. Don't worry we'll get this sorted.
     
  25. Deleted User

    Deleted User

    Guest

    Hello!

    I am attempting to export a prefab that consists of a mesh with blendshapes. I create an instance of the prefab in my scene, select it and click "Export Selected Object(s) as a single Fbx". The fbx file created is only 4kb in size and does not contain any meshes. This also occurs when exporting using "Export Entire Scene as Fbx". The file has "Directional Light" and "Main Camera" but nothing for the prefab in the scene. "Directional Light" and "Main Camera" also appear to only be empty transforms. This occurs when trying to export via the API as well.

    I've tried using different formats but each time I get the same result. I'm not getting any errors or useful output to the console unfortunately otherwise I would include it. I'm hoping that I'm just doing something silly. I'm currently using version 1.3.0 in Unreal 5.6.3p1.

    My best guess is this is happening on meshes with blendshapes. I have been able to export a mesh that consists of the same geometry without any blendshapes attached. Is this a known issue?
     
  26. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Eh, blendshapes? I knew I had forgotten something... I'm confused why it wouldn't export the "base" mesh but I guess I had forgotten about blendshapes. If you happen to have an fbx file (any fbx file) with blendshapes I should be able to add support for that in a matter of hours. The fbx format is quite open to interpretation and by analyzing a working fbx file I can get it right in first try.
     
  27. Deleted User

    Deleted User

    Guest

    Hello @UnLogick

    Thank you for your response. I've uploaded two fbx's here: https://www.dropbox.com/s/ymzyv8541pfd60n/blendtests.zip?dl=0. One is a simple sphere with blendshapes. The second is the same sphere skinned to joints with the same blendshapes. It would be good to ensure the blendshapes come through both skinned and not.

    Please let me know if you require anything else, and thank you!
     
  28. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Thanks @tonyb-vr I just downloaded and took a look in unity, I appreciate you making both the skinned and unskinned version however Unity converts them both into skinned meshes so I might end up doing the same depending on how different the two setups are.
     
  29. Deleted User

    Deleted User

    Guest

    @UnLogick sounds good. I appreciate you taking the time to implement this critical feature for us. Thank you!
     
  30. christophercimbaro

    christophercimbaro

    Joined:
    Aug 30, 2017
    Posts:
    12
    Hi,

    Just a quick question about your exporter, actually we're looking for an exporter Unity to Max, which conserve vertex painting information.
    In our production, we use vertex tool pro to paint differents materials by vertex with heighmap blending. To get a smooth iteration we need to conserve vertex painting when we export our mesh from Unity to 3DsMax. Edit the mesh in Max (adding vertex,...) and reexport this asset without loosing any vertex information in Unity.
     
  31. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Not entirely sure what you mean when you say vertex painting... but I dare say it does what you want... :D

    Color, Normals, Tangents, UVs, Skinning Weights, everything is exported so you should be good. :)
     
  32. GoRolyGo

    GoRolyGo

    Joined:
    Jul 7, 2015
    Posts:
    27
    before buy, i whould be intrested in a Seperate Objects in scene exporter with vertexcolor export feuture, for use in oculus "Meduim" to make maps

    Kind Regards
    Daniel
     
  33. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Not quite sure what you mean.

    Unity Fbx Exporter exports one or more objects into one or more fbx files easily. It supports vertex color as well as uv and textures.

    Integrating it into your project is easy, simply call the Export method once for each fbx file you wish to export. Give it the argument of the GameObjects that you wish to be added to the fbx file. These GameObjects can be from anywhere in your scene or from within a prefab. The hierarchies below these GameObjects will be recursively traversed and all meshes added to the fbx file. Though disabling this functionality would be easy.

    The "export scene" functionality is simply a call to export an fbx file with the argument of all root game objects in the scene.

    I hope this answered your question, if not feel free to ask again.

    Regards,
    Joen - UnLogick
     
  34. CYBERDAD

    CYBERDAD

    Joined:
    Sep 11, 2012
    Posts:
    29
    Hi,

    Before I buy your asset (FBX exporter) I would like to know:
    1 - If I can export multiple scene objects as a single mesh (FBX)
    2 - How does it handle the materials (textures) ? Does it export all the textures of the selected objects as a one single atlas or does it export it as different textures maps (base, normal map etc.,)
    3- What are the texture sizes. Does it export the texture size as it is in unit or does it compress or resize it ?

    Thanks.
     
  35. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    @UnLogick how is the Megasplat/Voxeland compatibility coming along? I thought I'd give you a lot of space/time to see what you can do considering as you said it wont be so easy of a task to figure out.
     
  36. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    @Ascensi I'd love to give you some good news, I've thought about it and still feel confident in my plan, but the truth is that I haven't had time to look at it yet. But it's now up at the top of my to-do list so soon(tm)
     
  37. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    @CYBERDAD
    1. Yes, you can give it an array of GameObjects and tell it to export those into a single fbx.
    2. You have a two options here.
      1. Export texture names only, no texture export
      2. Export pbr textures for diffuse, specular and normals
    3. When exporting textures the default is to look at the mainTexture of the material and use it's resolution.
     
  38. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    99
    Hi @UnLogick

    I just purchased the asset, and I get this error when I try to export either the full scene or just the selected objects (my environment):

    Screenshot - 10_5_2017 , 5_48_52 PM.png

    I have 16 GB of RAM, but it looks like that might not be enough for this program to run?

    Any suggestions?

    I tried restarting my computer, re-running it multiple times, to no avail.
     
  39. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    579
    I don't know if it's just a bug or not but if the system is running out of memory if you're running windows I'd try increasing the Virtual memory (maybe double the project Mb/GB) on the drive that you are trying to save to. I've had to do this for other programs with big projects Zbrush, 3DCoat etc.
     
  40. Lisk

    Lisk

    Joined:
    Oct 23, 2013
    Posts:
    99
    Thanks for the reply. I re-ran the application a few times, and after a few hours, I was able to get it to export.

    However, it looks very different than it does in Unity. See the below comparison:

    3dsmax.jpg vs. unity.jpg

    What am I doing wrong?
     
  41. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    I have no idea why git would crash, except if the entire system was out of memory. Id love to see the entire call stack hidden under the git crash dialog. Please mail me your scene and Ill investigate both the memory usage and why the result is wrong.
     
  42. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Looking at it now, the original idea was to use the lightmapper uv but I found something nicer. It turns out that Unity has a specific method for generating uvs for you. It's editor only but I assume that's gonna be fine for a first pass.

    I've split the task down to the following sub tasks.
    • Generate new UV
    • Create much slower render to texture algorithm that takes world space into account.
    • Add a texture exporter mode where you can specify WorldSpaceMatters this will take care of triplanar shaders and will also help terrain stretching by generating a new set of UVs based on triangle sizes. So if your terrain is rendered with a shader that makes it look less stretched it will not automatically be rendered into a tiny texture buffer essentially making it stretched again.
    • Add a texture exporter mode override component that you can manually place on certain objects to make them differ from the global set mode (to allow use of multiple modes inside a single fbx file)
     
  43. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    @Lisk unless of course you are exporting terrains at full QL, that will eat up memory like crazy. (Which is why I put warnings in the ui on these settings)
     
  44. Michaelbgdrs

    Michaelbgdrs

    Joined:
    May 1, 2014
    Posts:
    27
    @UnLogick Trying to build in Win , Unity 5.4.5.p5 and on compile scripts it stops due to this error.
    I am under heavy deadline and this is causing me serious issues.

    Kindly provide some support , also emailed you with no response.

    Error :

    Assets/Plugins/UnLogickFactory/FbxExporter/Scripts/FbxExporter.cs(298,41): error CS0103: The name `FixImportSettings' does not exist in the current context

    Warnings :

    Assets/Plugins/UnLogickFactory/FbxExporter/Scripts/FbxExporter.cs(309,33): warning CS0162: Unreachable code detected

    Thank you in advance

    Michael.
     
    Last edited: Oct 12, 2017
  45. Michaelbgdrs

    Michaelbgdrs

    Joined:
    May 1, 2014
    Posts:
    27
    Commenting the line out , let the build process start. Dont know if it works (runtime export based on the example script)
    with out issues . Will post back again with results.
     
  46. Michaelbgdrs

    Michaelbgdrs

    Joined:
    May 1, 2014
    Posts:
    27
    Not working , will wait for one more day.
     
  47. UnLogick

    UnLogick

    Joined:
    Jun 11, 2011
    Posts:
    1,745
    Quick note about the email situation:
    The mail auto reply is a warning that I don't check mail very often. Unity in their wisdom makes the support email address public so I get a ton of spam. The "correct" steps for support with a repro project like yours, is to do exactly what you did. Mail me and then write me a forum post either in this thread or pm :), I'll then search through the spam and find the mail.

    I took a look at this line in code and it's immediately obvious that I F***ed up. :)

    FixImportSettings is a method in the same file that only exists in the UnityEditor, yet I'm invoking it when making standalone builds. I've forgotten to test standalone builds and so I've move straight on to doing that now.

    This makes no absolutely no sense, there is no unreachable code at that location. I can only assume it's a mistake caused by the compiler error above.
    I've simplified the workflow of getting the FbxExporter dll into your build. Now you can simply mark the UnityFbxExporterXX.dll (currently UnityFbxExporter13.dll) to be included on the Windows 64 bit platform and it will locate it from the build's Plugins folder automatically.

    Please go to the asset store and download the new version 1.3.1.
     
  48. Michaelbgdrs

    Michaelbgdrs

    Joined:
    May 1, 2014
    Posts:
    27
    Perfect , many thanks for the fix and the procedural cables. Replied to your email as well. Will test asap once i return to work on Monday. You rock.
     
  49. Michaelbgdrs

    Michaelbgdrs

    Joined:
    May 1, 2014
    Posts:
    27
    @UnLogick I send an email again. Many thanks for the overall support.
    Michael.
     
  50. Maskvp

    Maskvp

    Joined:
    Jul 9, 2015
    Posts:
    14
    I can`t export vertex colors!
    I hope that will have a tutorial to explain how to save the vertex colors.

    I use unity2017.1.1f1 / unity Fbx Exporter 1.3.0

    Thanks