Missing shape keys in FBX export when using Triangulate Faces #104714

Closed
opened 2023-06-23 23:49:43 +02:00 by Thomas Barlow · 4 comments
Member

System Information
Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41

Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-06-19 17:26, hash: cedec09d0594
Worked:

Addon Information
Name: FBX format (5, 3, 4)
Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem

Short description of error
Enabling the Triangulate Faces option of the FBX exporter causes the shape keys of meshes to be missing in the export.

This is because the FBX exporter uses bpy.data.meshes.new_from_object() to create temporary copies of meshes when exporting to avoid modifying existing meshes when triangulating, but bpy.data.meshes.new_from_object() removes shape keys even when the mesh Object is not evaluated (issue tracked at blender/blender#109313).

This issue also affects exporting mesh Objects with Materials linked to the Object and can affect exporting meshes when Export Subdivision Surface is enabled in the exporter (anything that can set use_org_data to False in fbx_data_from_scene in export_fbx_bin.py when the Apply Modifiers option of the exporter is disabled or when the mesh Object has no applicable modifiers)

Exact steps for others to reproduce the error

  1. Create a mesh with shape keys (other than the 'Basis')
  2. Export as FBX with the Triangulate Faces option enabled
  3. Import the exported .fbx
  4. Observe that the shape keys are missing
**System Information** Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1070 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.41 **Blender Version** Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-06-19 17:26, hash: `cedec09d0594` Worked: **Addon Information** Name: FBX format (5, 3, 4) Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem **Short description of error** Enabling the Triangulate Faces option of the FBX exporter causes the shape keys of meshes to be missing in the export. This is because the FBX exporter uses `bpy.data.meshes.new_from_object()` to create temporary copies of meshes when exporting to avoid modifying existing meshes when triangulating, but `bpy.data.meshes.new_from_object()` removes shape keys even when the mesh Object is not evaluated (issue tracked at https://projects.blender.org/blender/blender/issues/109313). This issue also affects exporting mesh Objects with Materials linked to the Object and can affect exporting meshes when Export Subdivision Surface is enabled in the exporter (anything that can set `use_org_data` to `False` in `fbx_data_from_scene` in `export_fbx_bin.py` when the Apply Modifiers option of the exporter is disabled or when the mesh Object has no applicable modifiers) **Exact steps for others to reproduce the error** 1. Create a mesh with shape keys (other than the 'Basis') 1. Export as FBX with the Triangulate Faces option enabled 1. Import the exported .fbx 1. Observe that the shape keys are missing
Thomas Barlow added the
Type
Report
Priority
Normal
Status
Needs Triage
labels 2023-06-23 23:49:44 +02:00
Author
Member

For non-evaluated meshes, Object.to_mesh() would probably work as a replacement. This creates temporary meshes that do not get added to bpy.data.meshes and are owned by the Object they were created from. These temporary meshes can be forcefully freed at the end of the FBX export with Object.to_mesh_clear(). Though Mesh.copy() might work just as well.

For non-evaluated meshes, `Object.to_mesh()` would probably work as a replacement. This creates temporary meshes that do not get added to `bpy.data.meshes` and are owned by the Object they were created from. These temporary meshes can be forcefully freed at the end of the FBX export with `Object.to_mesh_clear()`. Though `Mesh.copy()` might work just as well.
Member

Thanks for the report. I can confirm.
Looks like there is no quick solution after reading blender/blender#109313
Mesh.copy() might be a workaround then?

Thanks for the report. I can confirm. Looks like there is no quick solution after reading https://projects.blender.org/blender/blender/issues/109313 Mesh.copy() might be a workaround then?
Pratik Borhade added
Status
Confirmed
Module
Add-ons (BF-Blender)
and removed
Status
Needs Triage
labels 2023-08-09 08:07:34 +02:00
Blender Bot added
Status
Resolved
and removed
Status
Confirmed
labels 2023-09-19 02:26:21 +02:00

Thanks for making this update, I was just testing in 4.0 and it works as advertised however it breaks any custom normals, say you use weightednormals, if you use the triangulate modifier last in the stack you would typically also select Keep Normals to prevent this happening however this prevents the shape keys from being preserved with the current solution.

Perhaps a better approach is remove the triangulate option from the fbx exporter and replace that with a preserve shape keys option and that is what triggers making a copy of the mesh etc. instead of just exporting it. At the moment I use a script to create a copy applying all the modifiers then copy shape keys etc. then export that with no modifiers.

Thanks for making this update, I was just testing in 4.0 and it works as advertised however it breaks any custom normals, say you use weightednormals, if you use the triangulate modifier last in the stack you would typically also select Keep Normals to prevent this happening however this prevents the shape keys from being preserved with the current solution. Perhaps a better approach is remove the triangulate option from the fbx exporter and replace that with a preserve shape keys option and that is what triggers making a copy of the mesh etc. instead of just exporting it. At the moment I use a script to create a copy applying all the modifiers then copy shape keys etc. then export that with no modifiers.
Author
Member

Thanks for making this update, I was just testing in 4.0 and it works as advertised however it breaks any custom normals, say you use weightednormals, if you use the triangulate modifier last in the stack you would typically also select Keep Normals to prevent this happening however this prevents the shape keys from being preserved with the current solution.

Perhaps a better approach is remove the triangulate option from the fbx exporter and replace that with a preserve shape keys option and that is what triggers making a copy of the mesh etc. instead of just exporting it. At the moment I use a script to create a copy applying all the modifiers then copy shape keys etc. then export that with no modifiers.

If this occurs even when exporting meshes without shape keys or in versions of Blender older than 4.0, please report a bug.

> Thanks for making this update, I was just testing in 4.0 and it works as advertised however it breaks any custom normals, say you use weightednormals, if you use the triangulate modifier last in the stack you would typically also select Keep Normals to prevent this happening however this prevents the shape keys from being preserved with the current solution. > > Perhaps a better approach is remove the triangulate option from the fbx exporter and replace that with a preserve shape keys option and that is what triggers making a copy of the mesh etc. instead of just exporting it. At the moment I use a script to create a copy applying all the modifiers then copy shape keys etc. then export that with no modifiers. > > If this occurs even when exporting meshes without shape keys or in versions of Blender older than 4.0, please report a bug.
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#104714
No description provided.