BlenderTools icon indicating copy to clipboard operation
BlenderTools copied to clipboard

Send to Unreal is broken in Blender 4.0 beta, FBX is corrupted/Missing data

Open funkysandwich opened this issue 1 year ago • 45 comments

Hi. Upon using Push Assets in Blender 4.0 beta, the assets fail to be imported by Unreal, but in Blender 3.6 it works fine. An export using Blender's built in FBX exporter in 4.0 does import. Just not ones from Push Assets.

Snippet from Unreal output log on import

LogFactory: FactoryCreateFile: StaticMesh with FbxFactory (0 0 C:/Users/funky/AppData/Local/Temp/blender/send2ue/data/StaticMesh/Blender40ExportTest.fbx)
LogFbx: Loading FBX Scene from C:/Users/funky/AppData/Local/Temp/blender/send2ue/data/StaticMesh/Blender40ExportTest.fbx
FBXImport: Warning: FBX Scene Loading Failed : 'File is corrupted Blender40ExportTest.fbx' 
FBXImport: Warning: Can't detect import type. No mesh is found or animation track. 
LogAssetTools: Warning: Failed to import 'C:/Users/funky/AppData/Local/Temp/blender/send2ue/data/StaticMesh/Blender40ExportTest.fbx'. Failed to create asset '/Game/UNSORTED/Blender40ExportTest'.

Tested with Blender 4.0.0 Beta, and Send to Unreal 2.4.2

funkysandwich avatar Oct 17 '23 23:10 funkysandwich

Same for Blender 4.1 I hope for a quick fix since Blender files 4.0 and above are not compatible with 3.65 anymore.

kapi113 avatar Nov 03 '23 14:11 kapi113

Same for Blender 4.0 general release.

universalconquistador avatar Nov 17 '23 22:11 universalconquistador

+1 Generated FBX for UE import flagged as corrupted. UE: 5.3.1 Blender 4.0.1

The very same file works fine with Blender 3.6.5.

jesseunderdog avatar Nov 18 '23 21:11 jesseunderdog

Same issues for me. Blender 4.0/ UE 5.3. Was previously working fine with Blender 3.6

grahamwheaton avatar Nov 20 '23 10:11 grahamwheaton

+1 having the same problem here. blender 4.0

LiuYangArt avatar Nov 23 '23 02:11 LiuYangArt

Screenshot 2023-11-24 095319 same here, blender 4.0.1

somaprod avatar Nov 24 '23 07:11 somaprod

Glad to know it isn't my mesh. Almost had a heart attack here. Same to me.

eatmylazer avatar Nov 25 '23 16:11 eatmylazer

same here, fixed it by exporting the 4.0 project as an fbx and importing it into a 3.5 beta version.

Ondicknek avatar Nov 26 '23 14:11 Ondicknek

same here, fixed it by exporting the 4.0 project as an fbx and importing it into a 3.5 beta version.

I think it is just the plugin that doesn't work. Exporting a fbx manually and importing it into unreal works

Kingfelix23 avatar Nov 26 '23 16:11 Kingfelix23

yeah you could export without the plugin but its super slow and annoying

Ondicknek avatar Nov 27 '23 15:11 Ondicknek

Yes, of course, but why not just open the blend file in 3.6 instead and use send2ue as usual, no reason to export to FBX, or?

Kingfelix23 avatar Nov 27 '23 15:11 Kingfelix23

The same with me. I had a look into the code and there seem to be some workarounds and fixes on how the 3.x series handled FBX exports. From what I see the original code (3.x) was copied and slightly altered/fixed and the original methods of the fbx exporter were overwritten during export. This for sure messes up the new 4.0 fbx exporter code. I did a quick test and reverted the overwrite and from what I see is that the export now works without any noticable problems so far. Maybe this observation helps to fix this problem.

mlubich avatar Nov 30 '23 16:11 mlubich

can you share the fix version ? Thanks

mlubich @.***> 于 2023年12月1日周五 00:30写道:

The same with me. I had a look into the code and there seem to be some workarounds and fixes on how the 3.x series handled FBX exports. From what I see the original code (3.x) was copied and slightly altered/fixed and the original methods of the fbx exporter were overwritten during export. This for sure messes up the new 4.0 fbx exporter code. I did a quick test and reverted the overwrite and from what I see is that the export now works without any noticable problems so far. Maybe this observation helps to fix this problem.

— Reply to this email directly, view it on GitHub https://github.com/EpicGames/BlenderTools/issues/676#issuecomment-1834114399, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBCL6SSPOV763RSGXDH2BTYHCYAVAVCNFSM6AAAAAA6ET5FV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZUGEYTIMZZHE . You are receiving this because you commented.Message ID: @.***>

LiuYangArt avatar Dec 01 '23 02:12 LiuYangArt

I am a bit unsure what you mean. Did you change code in send2ue or in Blender itself?

Kingfelix23 avatar Dec 01 '23 08:12 Kingfelix23

I am a bit unsure what you mean. Did you change code in send2ue or in Blender itself?

I did change the python code of the send2ue plugin.

The change I did is a crude hack, as it bypasses all the fixes/additions done by the authors of send2ue. There are certainly problems with this approach as I do not know what was fixed in the new blender FBX export code and which send2ue fixes are still needed.

Here is a comment from the io.export method in which the send2ue developers are describing the overall idea:

Note that this function imports the blender FBX addon's module and monkey patches
some functions to fix the scale factor and world origins of the objects, so that they import
nicely into unreal engine.

If you want to experminet yourself you can do the following:

  • Lets call send2ue_path the path were your plugin is installed (You find the path in blender in the preferences/Add-on/Pipeline:Send to Unreal)
  • Edit the file <send2ue_path>/core/io/fbx.py
  • Go to line 538 and 552 and comment all the lines were the original attributes are overwritten
    #export_fbx_bin.fbx_animations_do = fbx_animations_do
    #export_fbx_bin.fbx_data_armature_elements = fbx_data_armature_elements
    #export_fbx_bin.fbx_data_object_elements = fbx_data_object_elements
    #export_fbx_bin.fbx_data_bindpose_element = fbx_data_bindpose_element
...
    #export_fbx_bin.fbx_animations_do = original_fbx_animations_do
    #export_fbx_bin.fbx_data_armature_elements = original_fbx_data_armature_elements
    #export_fbx_bin.fbx_data_object_elements = original_fbx_data_object_elements
    #export_fbx_bin.fbx_data_bindpose_element = original_fbx_data_bindpose_element

Again, I do not think that this approach is a feasible stable solution. The original authors should have a look at the current blender 4.0 fbx implementation and decide if all any of fixes present in send2ue are still needed.

mlubich avatar Dec 01 '23 09:12 mlubich

Ok, cool. thanks.

I guess you dont know whether it was a specific attribute was the culprit, or do you have to turn them all of, or maybe that doesnt matter?

Kingfelix23 avatar Dec 01 '23 09:12 Kingfelix23

I guess you dont know whether it was a specific attribute was the culprit, or do you have to turn them all of, or maybe that doesnt matter?

No, I do not know. I just deactivated all of them just to see if this makes any difference. I only have one project I am transferring from blender to unreal, so that sample size to catch any problems is quite low :) I do not export any animations or armatures, just plain static meshes.

mlubich avatar Dec 01 '23 09:12 mlubich

Here's a proper fix until addon is updated:

the fbx.py file mentioned above is what we need to change

go to line 35, add elem_data_single_char to the list so it looks like

from io_scene_fbx.fbx_utils import (
    FBX_MODELS_VERSION,
    FBX_POSE_BIND_VERSION,
    FBX_DEFORMER_SKIN_VERSION,
    FBX_DEFORMER_CLUSTER_VERSION,
    BLENDER_OBJECT_TYPES_MESHLIKE,
    units_convertor_iter,
    matrix4_to_array,
    get_fbx_uuid_from_key,
    get_blenderID_name,
    get_blender_bindpose_key,
    get_blender_anim_stack_key,
    get_blender_anim_layer_key,
    elem_empty,
    elem_data_single_bool,
    elem_data_single_int32,
    elem_data_single_int64,
    elem_data_single_float64,
    elem_data_single_string,
    elem_data_single_int32_array,
    elem_data_single_float64_array,
    elem_properties,
    elem_props_template_init,
    elem_props_template_set,
    elem_props_template_finalize,
    fbx_name_class,
    elem_data_single_char
)

Search for b"Shading" and replace elem_data_single_bool(model, b"Shading", True) with elem_data_single_char(model, b"Shading", b"\x01")

That's all!

JoshQuake avatar Dec 05 '23 22:12 JoshQuake

Here's a proper fix until addon is updated:

the fbx.py file mentioned above is what we need to change

go to line 35, add elem_data_single_char to the list so it looks like

from io_scene_fbx.fbx_utils import (
    FBX_MODELS_VERSION,
    FBX_POSE_BIND_VERSION,
    FBX_DEFORMER_SKIN_VERSION,
    FBX_DEFORMER_CLUSTER_VERSION,
    BLENDER_OBJECT_TYPES_MESHLIKE,
    units_convertor_iter,
    matrix4_to_array,
    get_fbx_uuid_from_key,
    get_blenderID_name,
    get_blender_bindpose_key,
    get_blender_anim_stack_key,
    get_blender_anim_layer_key,
    elem_empty,
    elem_data_single_bool,
    elem_data_single_int32,
    elem_data_single_int64,
    elem_data_single_float64,
    elem_data_single_string,
    elem_data_single_int32_array,
    elem_data_single_float64_array,
    elem_properties,
    elem_props_template_init,
    elem_props_template_set,
    elem_props_template_finalize,
    fbx_name_class,
    elem_data_single_char
)

Search for b"Shading" and replace elem_data_single_bool(model, b"Shading", True) with elem_data_single_char(model, b"Shading", b"\x01")

That's all!

Thanks for the instructions. I just tried it and it worked for me in Blender 4.1 Alpha.

geekrelief avatar Dec 05 '23 22:12 geekrelief

Here's a proper fix until addon is updated:

the fbx.py file mentioned above is what we need to change

go to line 35, add elem_data_single_char to the list so it looks like

from io_scene_fbx.fbx_utils import (
    FBX_MODELS_VERSION,
    FBX_POSE_BIND_VERSION,
    FBX_DEFORMER_SKIN_VERSION,
    FBX_DEFORMER_CLUSTER_VERSION,
    BLENDER_OBJECT_TYPES_MESHLIKE,
    units_convertor_iter,
    matrix4_to_array,
    get_fbx_uuid_from_key,
    get_blenderID_name,
    get_blender_bindpose_key,
    get_blender_anim_stack_key,
    get_blender_anim_layer_key,
    elem_empty,
    elem_data_single_bool,
    elem_data_single_int32,
    elem_data_single_int64,
    elem_data_single_float64,
    elem_data_single_string,
    elem_data_single_int32_array,
    elem_data_single_float64_array,
    elem_properties,
    elem_props_template_init,
    elem_props_template_set,
    elem_props_template_finalize,
    fbx_name_class,
    elem_data_single_char
)

Search for b"Shading" and replace elem_data_single_bool(model, b"Shading", True) with elem_data_single_char(model, b"Shading", b"\x01")

That's all!

I was having the same issue with the fully released version of blender 4.0 and this worked perfectly! Until the Send2UE devs manage to make a fix for this version of blender, this should definetely be the pinned fix. Thanks for figuring this out :)

AveryX01 avatar Dec 06 '23 04:12 AveryX01

Im like not getting any error but my exported mesh from blender to unreal is not updated when I press export. Even when I add new object to Export collection it is not exported. Any ide what can be with that?

vikista avatar Dec 09 '23 00:12 vikista

Well, it isn't working at all in 4.0 if you dont patch the file with the code AveryX01 provided. If you run earlier maybe the python setting isn't turned on, but it it isn't related to 4.0 you would probably be better of making a new thread

Kingfelix23 avatar Dec 09 '23 14:12 Kingfelix23

Well, it is a different version of Blender, mine is now 4.0.2.

so 9. 12. 2023 o 15:29 Kingfelix23 @.***> napísal(a):

Well, it isn't working at all in 4.0 if you dont patch the file with the code AveryX01 provided. If you run earlier maybe the python setting isn't turned on, but it it isn't related to 4.0 you would probably be better of making a new thread

— Reply to this email directly, view it on GitHub https://github.com/EpicGames/BlenderTools/issues/676#issuecomment-1848425421, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR7345EC6PWAE2KIQSJ3VQLYIRYVJAVCNFSM6AAAAAA6ET5FV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYGQZDKNBSGE . You are receiving this because you commented.Message ID: @.***>

vikista avatar Dec 09 '23 14:12 vikista

Strange, it works for me, are you sure you put in the code correctly?

Kingfelix23 avatar Dec 09 '23 15:12 Kingfelix23

@JoshQuake Have you had any issues with normals? I tried exporting Suzanne and the normals are off on some faces. In this case turning on smooth shading looks correct. In other meshes I've edited sometimes flat works, but smooth does not. I tried the different geometry smoothing options for Send To Unreal, but nothing seems to help.

Suzanne flat has problems https://github.com/EpicGames/BlenderTools/assets/27040/5426664b-9120-4055-870c-157bfe505491

Some of the rounded corners have problems blender_OEDU5KXdRK

Rounded cube https://github.com/EpicGames/BlenderTools/assets/27040/d7a388f9-9ed0-4715-aa9b-421c373a3a40

geekrelief avatar Dec 09 '23 19:12 geekrelief

Im like not getting any error but my exported mesh from blender to unreal is not updated when I press export. Even when I add new object to Export collection it is not exported. Any ide what can be with that?

Did you miss the comma when adding elem_data_single_char to the list? Maybe open console and see if there is an error.

fbx_name_class,
elem_data_single_char

JoshQuake avatar Dec 09 '23 21:12 JoshQuake

@JoshQuake Have you had any issues with normals? I tried exporting Suzanne and the normals are off on some faces. In this case turning on smooth shading looks correct. In other meshes I've edited sometimes flat works, but smooth does not. I tried the different geometry smoothing options for Send To Unreal, but nothing seems to help.

Suzanne flat has problems https://github.com/EpicGames/BlenderTools/assets/27040/5426664b-9120-4055-870c-157bfe505491

Some of the rounded corners have problems blender_OEDU5KXdRK

Rounded cube https://github.com/EpicGames/BlenderTools/assets/27040/d7a388f9-9ed0-4715-aa9b-421c373a3a40

I couldn't tell ya. I only went into the newer fbx io plugin to see what values could have changed. Only difference I saw was how Shading True was being set and it solved the crash.

I tried exporting a flat suzanne and rounded cube but I do not get the same result as you.

Blender 4.0.1

image

JoshQuake avatar Dec 09 '23 21:12 JoshQuake

ld have changed. Only difference I saw was how Shading True was being set and it solved the crash.

Thanks for double checking for me. I guess something is wrong with my build of Blender. I'll try 4.0.1. Thanks! Edit: Thanks to JoshQuake for telling me I was missing UV info on my character which led to the shading issues.

geekrelief avatar Dec 11 '23 17:12 geekrelief

Here's a proper fix until addon is updated:

the fbx.py file mentioned above is what we need to change

go to line 35, add elem_data_single_char to the list so it looks like

from io_scene_fbx.fbx_utils import (
    FBX_MODELS_VERSION,
    FBX_POSE_BIND_VERSION,
    FBX_DEFORMER_SKIN_VERSION,
    FBX_DEFORMER_CLUSTER_VERSION,
    BLENDER_OBJECT_TYPES_MESHLIKE,
    units_convertor_iter,
    matrix4_to_array,
    get_fbx_uuid_from_key,
    get_blenderID_name,
    get_blender_bindpose_key,
    get_blender_anim_stack_key,
    get_blender_anim_layer_key,
    elem_empty,
    elem_data_single_bool,
    elem_data_single_int32,
    elem_data_single_int64,
    elem_data_single_float64,
    elem_data_single_string,
    elem_data_single_int32_array,
    elem_data_single_float64_array,
    elem_properties,
    elem_props_template_init,
    elem_props_template_set,
    elem_props_template_finalize,
    fbx_name_class,
    elem_data_single_char
)

Search for b"Shading" and replace elem_data_single_bool(model, b"Shading", True) with elem_data_single_char(model, b"Shading", b"\x01")

That's all!

This solved the issue for me in Blender 4.0.1 Thanks!

BiffKakan avatar Dec 28 '23 11:12 BiffKakan

Here's a proper fix until addon is updated:

the fbx.py file mentioned above is what we need to change

go to line 35, add elem_data_single_char to the list so it looks like

from io_scene_fbx.fbx_utils import (
    FBX_MODELS_VERSION,
    FBX_POSE_BIND_VERSION,
    FBX_DEFORMER_SKIN_VERSION,
    FBX_DEFORMER_CLUSTER_VERSION,
    BLENDER_OBJECT_TYPES_MESHLIKE,
    units_convertor_iter,
    matrix4_to_array,
    get_fbx_uuid_from_key,
    get_blenderID_name,
    get_blender_bindpose_key,
    get_blender_anim_stack_key,
    get_blender_anim_layer_key,
    elem_empty,
    elem_data_single_bool,
    elem_data_single_int32,
    elem_data_single_int64,
    elem_data_single_float64,
    elem_data_single_string,
    elem_data_single_int32_array,
    elem_data_single_float64_array,
    elem_properties,
    elem_props_template_init,
    elem_props_template_set,
    elem_props_template_finalize,
    fbx_name_class,
    elem_data_single_char
)

Search for b"Shading" and replace elem_data_single_bool(model, b"Shading", True) with elem_data_single_char(model, b"Shading", b"\x01")

That's all!

Chiming in to say this also got me up and running with Blender 4.x, thank you!

maxpiepenbrink avatar Jan 05 '24 09:01 maxpiepenbrink