FBX export fails with some very simple material setups #41396

Closed
opened 2014-08-11 11:18:30 +02:00 by Arnaud Couturier · 16 comments

System Information
Win7 Home premium 64 SP1, i7, Nvidia GTX675m

Blender Version
2.71 official

Short description of error
The FBX exporter gives an error when trying to export a mesh that is using some materials linked from other .blend files.

Exact steps for others to reproduce the error
It's very easy to reproduce:

  1. Create and save a .blend file with 3 simple default materials in it, and one of them is using nodes (just leave the default node setup for that material)
  2. In a second .blend file, link those 3 materials, then assign them to a mesh
  3. Try to export the mesh to FBX => fail
**System Information** Win7 Home premium 64 SP1, i7, Nvidia GTX675m **Blender Version** 2.71 official **Short description of error** The FBX exporter gives an error when trying to export a mesh that is using some materials linked from other .blend files. **Exact steps for others to reproduce the error** It's very easy to reproduce: 1) Create and save a .blend file with 3 simple default materials in it, and one of them is using nodes (just leave the default node setup for that material) 2) In a second .blend file, link those 3 materials, then assign them to a mesh 3) Try to export the mesh to FBX => fail

Changed status to: 'Open'

Changed status to: 'Open'
Campbell Barton was assigned by Arnaud Couturier 2014-08-11 11:18:30 +02:00

Added subscriber: @piiichan

Added subscriber: @piiichan

Two example files : example_files.7z
One (lib_materials.blend) contains the 3 materials.
And the other (ref_materials.blend) has a cube that links to them. Try to export the cube to FBX, it won't work.

Two example files : [example_files.7z](https://archive.blender.org/developer/F102429/example_files.7z) One (lib_materials.blend) contains the 3 materials. And the other (ref_materials.blend) has a cube that links to them. Try to export the cube to FBX, it won't work.

Added subscriber: @mont29

Added subscriber: @mont29
Campbell Barton was unassigned by Bastien Montagne 2014-08-11 11:55:03 +02:00
Bastien Montagne self-assigned this 2014-08-11 11:55:03 +02:00

Added subscriber: @ideasman42

Added subscriber: @ideasman42

This issue was referenced by 07747bcf64

This issue was referenced by 07747bcf64963eefaff8aaa9cee24ed652fda5b9

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit 07747bcf64.

Closed by commit 07747bcf64.

I modified the line you committed
(https://developer.blender.org/rBA07747bcf64963eefaff8aaa9cee24ed652fda5b9)
in my export_fbx_bin.py.

And now my exported FBX models don't have the materials that are using nodes, is this normal ? (I'm still using Blender 2.71 official to test your change)
If that's normal, then I think it's not an acceptable solution at all.

The way I expect it to work is: my exported FBX models have all their materials, just like in Blender. Even node-based materials. If node-based materials can't be correctly "coded" in FBX, then just let them be default materials in the FBX file, so we can tweak/rebuild/code them in the target game engine/renderer. Right now I can't do anything, they're just gone.

I modified the line you committed (https://developer.blender.org/rBA07747bcf64963eefaff8aaa9cee24ed652fda5b9) in my export_fbx_bin.py. And now my exported FBX models don't have the materials that are using nodes, is this normal ? (I'm still using Blender 2.71 official to test your change) If that's normal, then I think it's not an acceptable solution at all. The way I expect it to work is: my exported FBX models have all their materials, just like in Blender. Even node-based materials. If node-based materials can't be correctly "coded" in FBX, then just let them be default materials in the FBX file, so we can tweak/rebuild/code them in the target game engine/renderer. Right now I can't do anything, they're just gone.

Nodal materials were never supported at all. Bug was that they were still being tried, in this specific part of the code, when they should not.

I do not really see the point in exporting dummy data, if you have to re-create them in other app, you can as well re-create them from scratch…

And no, exporting nodal materials is not considered a TODO currently, it does not really makes sense anyway.

Nodal materials were never supported at all. Bug was that they were still being tried, in this specific part of the code, when they should not. I do not really see the point in exporting dummy data, if you have to re-create them in other app, you can as well re-create them from scratch… And no, exporting nodal materials is not considered a TODO currently, it does not really makes sense anyway.

if you have to re-create them in other app, you can as well re-create them from scratch…

I do recreate them, but I can't necessarily be able to specify in other apps what parts of the mesh should have them applied, I use Blender for that.

I'm using the Unity game engine, it lets me do whatever I want with a material from an imported 3d model, like writing custom realtime shaders. But the sub-meshes Unity generates for an imported 3d model are per material, and this info is in the FBX file. If the material is not even present in the FBX file, I can't apply different materials to different parts of a mesh.

Node-based materials are very common in Blender nowadays. Does it mean that a mesh should have zero material if all of its materials are node-based ? It doesn't make sense to me... There should be default placeholder materials in the FBX file instead, meaning "There is a material here, we weren't able to correctly describe it in FBX's terms, but it should be there". With the current solution, 100% of the information is lost, even the name of the material, and the parts of the mesh it's applied to.

Anyway, I can work around it using a bit of scripting in Blender.
And thanks for the quick "fix" nevertheless :)

> if you have to re-create them in other app, you can as well re-create them from scratch… I do recreate them, but I can't necessarily be able to specify in other apps what parts of the mesh should have them applied, I use Blender for that. I'm using the Unity game engine, it lets me do whatever I want with a material from an imported 3d model, like writing custom realtime shaders. But the sub-meshes Unity generates for an imported 3d model are per material, and this info is in the FBX file. If the material is not even present in the FBX file, I can't apply different materials to different parts of a mesh. Node-based materials are very common in Blender nowadays. Does it mean that a mesh should have zero material if all of its materials are node-based ? It doesn't make sense to me... There should be default placeholder materials in the FBX file instead, meaning "There is a material here, we weren't able to correctly describe it in FBX's terms, but it should be there". With the current solution, 100% of the information is lost, even the name of the material, and the parts of the mesh it's applied to. Anyway, I can work around it using a bit of scripting in Blender. And thanks for the quick "fix" nevertheless :)

Oh… did not thought about the 'multimats per mesh' case :/

Will have a look at that, then.

Oh… did not thought about the 'multimats per mesh' case :/ Will have a look at that, then.

Better fix in e35de9d174 then! :)

Now unexportable mats are still 'written' as default FBX materials, so they are usable as placeholders.

Better fix in e35de9d174 then! :) Now unexportable mats are still 'written' as default FBX materials, so they are usable as placeholders.

I copy/pasted your changes from https://developer.blender.org/rBAe35de9d174291adab3b28ba660962dc0b084d9d3 into my export_fbx_bin.py
I'm still in Blender 2.71, so I hope your changes are compatible with that version... (Replacing my whole file with the new one gave me errors on export)

I tried exporting 3d models (old and new) that are using nodal materials, and it looks like the FBX export is now working fine. I just get a default diffuse gray material in Unity in place of my nodal materials, which is just what I expect, excellent.
I'm just speaking for myself here, but I think this behavior is the most logical one. It's also the most conservative approach, which is better than a destructive one.

I found another issue: if I add a material slot to the mesh, but if I leave it empty (no material assigned to it), the export fails. See image below
bug_with_empty_material_slot.png

I copy/pasted your changes from https://developer.blender.org/rBAe35de9d174291adab3b28ba660962dc0b084d9d3 into my export_fbx_bin.py I'm still in Blender 2.71, so I hope your changes are compatible with that version... (Replacing my whole file with the new one gave me errors on export) I tried exporting 3d models (old and new) that are using nodal materials, and it looks like the FBX export is now working fine. I just get a default diffuse gray material in Unity in place of my nodal materials, which is just what I expect, excellent. I'm just speaking for myself here, but I think this behavior is the most logical one. It's also the most conservative approach, which is better than a destructive one. I found another issue: if I add a material slot to the mesh, but if I leave it empty (no material assigned to it), the export fails. See image below ![bug_with_empty_material_slot.png](https://archive.blender.org/developer/F102516/bug_with_empty_material_slot.png)

Thanks, fixed in 3365561271 (own stupid mistake :/ ).

Thanks, fixed in 3365561271 (own stupid mistake :/ ).

This issue was referenced by 3f0687b8ad95e7fec6f1469389f08f5dd0915f32

This issue was referenced by 3f0687b8ad95e7fec6f1469389f08f5dd0915f32
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#41396
No description provided.