KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 316 forks source link

Exporting custom normals imported from an FBX throws error #338

Closed JohannesDeml closed 5 years ago

JohannesDeml commented 5 years ago

Blender version: 2.80.0-git.168d3fd528c4-windows64 Import-Export: FBX format version: 4.14.3 Import-Export glTF 2.0 format version: 0.0.1

I imported a very simple cube object from an FBX (created with C4D) and wanted to export it to glTF. I'm getting an error that an element-wise multiplication between a Matrix and a Vector is not allowed.

I did a bit of research and got some interesting findings that might help pinpoint the problem:

Here are the blend files from 2.79 which has not problem, and 2.80 with throws the error when exporting. FBXImportCustomNormals.zip

Error:

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\__init__.py", line 354, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 39, in save
    json, buffer = __export(export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 53, in __export
    __gather_gltf(exporter, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 68, in __gather_gltf
    scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 34, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 52, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(blender_object, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 40, in gather_node
    children=__gather_children(blender_object, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 90, in __gather_children
    node = gather_node(child_object, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 44, in gather_node
    mesh=__gather_mesh(blender_object, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_nodes.py", line 187, in __gather_mesh
    result = gltf2_blender_gather_mesh.gather_mesh(blender_mesh, vertex_groups, modifiers, skip_filter, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_mesh.py", line 38, in gather_mesh
    primitives=__gather_primitives(blender_mesh, vertex_groups, modifiers, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_mesh.py", line 89, in __gather_primitives
    return gltf2_blender_gather_primitives.gather_primitives(blender_mesh, vertex_groups, modifiers, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_primitives.py", line 55, in gather_primitives
    material=__gather_materials(internal_primitive, blender_mesh, modifiers, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_primitives.py", line 70, in __gather_materials
    return gltf2_blender_gather_materials.gather_material(material, mesh_double_sided, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_materials.py", line 52, in gather_material
    pbr_metallic_roughness=__gather_pbr_metallic_roughness(blender_material, export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_materials.py", line 160, in __gather_pbr_metallic_roughness
    export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 32, in gather_material_pbr_metallic_roughness
    base_color_texture=__gather_base_color_texture(blender_material, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_materials_pbr_metallic_roughness.py", line 97, in __gather_base_color_texture
    return gltf2_blender_gather_texture_info.gather_texture_info((base_color_socket,), export_settings)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 51, in wrapper_cached
    result = func(*args)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_texture_info.py", line 34, in gather_texture_info
    extensions=__gather_extensions(blender_shader_sockets_or_texture_slots, export_settings),
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_gather_texture_info.py", line 60, in __gather_extensions
    texture_transform = gltf2_blender_get.get_texture_transform_from_texture_node(texture_node)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_get.py", line 402, in get_texture_transform_from_texture_node
    mapping_transform = inverted(mapping_transform)
  File "C:\Program Files\Blender Foundation\blender-2.80.0-git.168d3fd528c4-windows64\2.80\scripts\addons\io_scene_gltf2\blender\exp\gltf2_blender_get.py", line 394, in inverted
    new_offset = Matrix.Rotation(-rotation, 3, 'Z') * Vector((-offset[0], -offset[1], 1))
TypeError: Element-wise multiplication: not supported between 'Matrix' and 'Vector' types

location: <unknown location>:-1

Any ideas of where the problem might be?

ghost commented 5 years ago

I can not reproduce the error with the most recent Blender and addon versions. I could not export the blend file first, because an image is missing, but after I added some image, everything worked fine.

JohannesDeml commented 5 years ago

I can not reproduce the error with the most recent Blender and addon versions. I could not export the blend file first, because an image is missing, but after I added some image, everything worked fine.

Hey @UX3D-schmithuesen , thanks for trying to reproduce the error. I just tested it as well with blender-2.80.0-git.e795dd4a20a1-windows64 (latest version). I still get the same error. Did you use the default settings for export? and did you try exporting the file FBXImportCustomNormals2.80.blend?

ghost commented 5 years ago

Yes, all on default... Maybe the issue only exists on Windows since I'm running Linux – I will check that in a minute.

JohannesDeml commented 5 years ago

Yes, all on default... Maybe the issue only exists on Windows since I'm running Linux – I will check that in a minute.

Thanks again for the quick response! I just checked if the current version of the plugin from the master has the problem as well. Turns out, that one let's me export the file without an error. Do you maybe use the latest commit of this repo as well instead of version 0.0.1 from the install itself?

Sorry for talking up your time, with the newest commit I get a completely correct export, this issue might be of interest for other until the default version of the blender 2.80 beta is updated.

ghost commented 5 years ago

Do you maybe use the latest commit of this repo as well instead of version 0.0.1 from the install itself?

You are right! But good that it seems to be fixed now :+1:

donmccurdy commented 5 years ago

Just to clarify – the error has been fixed, but custom normals are not exported yet, right?

JohannesDeml commented 5 years ago

Hi @donmccurdy, I think so yes. Our mesh does not really depend that much on the custom normals (it's just from Cinema's Phong brakes, but those will also be applied by blender, so I can't really tell from our mesh. But from what I read from the other issues the export probably does not work (I can't check though).

donmccurdy commented 5 years ago

Ok, I guess https://github.com/KhronosGroup/glTF-Blender-IO/issues/309 or https://github.com/KhronosGroup/glTF-Blender-IO/issues/230 probably track that issue anyway.