Moguri / blend2bam

A CLI tool to convert Blender blend files to Panda3D BAM files
MIT License
68 stars 18 forks source link

Blender 3.4, ValueError: field 'COLOR_00' occurs more than once #73

Closed Germanunkol closed 1 year ago

Germanunkol commented 1 year ago

I'm running into errors when using blend2bam with Blender 3.4. While trying to create a minimal example for another issue, I'm now running into a new error: ValueError: field 'COLOR_00' occurs more than once

Here's the file: armature_test_3.4.blend.zip

Using blend2bam version 0.20.

Here's how I call blend2bam: python3 -m blend2bam --blender-dir ~/Software/blender-3.4.0-linux-x64/ ~/Projects/CreatureGenerator/armature_test_3.4.blend

Result:

armature_test_3.4.bam  -m pbr
Blender 3.4.0 (hash a95bf1ac01be built 2022-12-07 01:27:35)
Read prefs: /home/username/.config/blender/3.4/config/userpref.blend
srcroot: /home/username/Projects/CreatureGenerator/
Exporting: ['/home/username/Projects/CreatureGenerator/armature_test_3.4.blend']
Export to: /tmp/
Read blend: /home/username/Projects/CreatureGenerator/armature_test_3.4.blend
Converting .blend file (/home/username/Projects/CreatureGenerator/armature_test_3.4.blend) to .gltf (/tmp/armature_test_3.4.gltf)
20:54:24 | INFO: Draco mesh compression is available, use library at /home/username/Software/blender-3.4.0-linux-x64/3.4/python/lib/python3.10/site-packages/libextern_draco.so
20:54:25 | INFO: Starting glTF 2.0 export
20:54:25 | INFO: Extracting primitive: Creature.003
Traceback (most recent call last):
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/__init__.py", line 693, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 35, in save
    json, buffer = __export(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 52, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 66, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 30, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 69, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 34, in gather_node
    children=__gather_children(vnode, blender_object, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 73, in __gather_children
    node = gather_node(c, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 38, in gather_node
    mesh=__gather_mesh(vnode, blender_object, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 246, in __gather_mesh
    result = gltf2_blender_gather_mesh.gather_mesh(blender_mesh,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 61, in gather_mesh
    primitives=__gather_primitives(blender_mesh, uuid_for_skined_data, vertex_groups, modifiers, materials, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 147, in __gather_primitives
    return gltf2_blender_gather_primitives.gather_primitives(blender_mesh,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 69, in gather_primitives
    blender_primitives = __gather_cache_primitives(blender_mesh, uuid_for_skined_data,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 115, in __gather_cache_primitives
    blender_primitives = gltf2_blender_gather_primitives_extract.extract_primitives(
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py", line 22, in extract_primitives
    primitive_creator.create_dots_data_structure()
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py", line 290, in create_dots_data_structure
    self.dots = np.empty(len(self.blender_mesh.loops), dtype=np.dtype(dot_fields))
ValueError: field 'COLOR_00' occurs more than once
Error: Python: Traceback (most recent call last):
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/__init__.py", line 693, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 35, in save
    json, buffer = __export(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 52, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 66, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 30, in gatheTraceback (most recent call last):
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blend2gltf/../blender_script_common.py", line 32, in convert_files
    convertfn(settings, src, dst)
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blend2gltf/blender28_script.py", line 168, in export_gltf
    bpy.ops.export_scene.gltf(
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/modules/bpy/ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), None, kw)
RuntimeError: Error: Python: Traceback (most recent call last):
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/__init__.py", line 693, in execute
    return gltf2_blender_export.save(context, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 35, in save
    json, buffer = __export(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 52, in __export
    __gather_gltf(exporter, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 66, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 30, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 69, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 34, in gather_node
    children=__gather_children(vnode, blender_object, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 73, in __gather_children
    node = gather_node(c, export_settings)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 38, in gather_node
    mesh=__gather_mesh(vnode, blender_object, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 246, in __gather_mesh
    result = gltf2_blender_gather_mesh.gather_mesh(blender_mesh,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 61, in gather_mesh
    primitives=__gather_primitives(blender_mesh, uuid_for_skined_data, vertex_groups, modifiers, materials, export_settings),
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_mesh.py", line 147, in __gather_primitives
    return gltf2_blender_gather_primitives.gather_primitives(blender_mesh,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 69, in gather_primitives
    blender_primitives = __gather_cache_primitives(blender_mesh, uuid_for_skined_data,
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 38, in wrapper_cached
    result = func(*args, **kwargs)
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives.py", line 115, in __gather_cache_primitives
    blender_primitives = gltf2_blender_gather_primitives_extract.extract_primitives(
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py", line 22, in extract_primitives
    primitive_creator.create_dots_data_structure()
  File "/home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py", line 290, in create_dots_data_structure
    self.dots = np.empty(len(self.blender_mesh.loops), dtype=np.dtype(dot_fields))
ValueError: field 'COLOR_00' occurs more than once
Location: /home/username/Software/blender-3.4.0-linux-x64/3.4/scripts/modules/bpy/ops.py:113

Failed to convert /home/username/Projects/CreatureGenerator/armature_test_3.4.blend to gltf
... truncatedTraceback (most recent call last):
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/cli.py", line 88, in convert
    src2tmp.convert_single(srcfile, tmpfile.name)
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blend2gltf/__init__.py", line 46, in convert_single
    self.convert_batch(srcroot, dstdir, files)
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blend2gltf/__init__.py", line 61, in convert_batch
    blenderutils.run_blender_script(self.script_file, args, blenderdir=blenderdir)
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blenderutils.py", line 35, in run_blender_script
    blenderbin=blenderbin
  File "/home/username/.local/lib/python3.6/site-packages/blend2bam/blenderutils.py", line 25, in run_blender
    subprocess.check_call(binpath + ['--background'] + args, stdout=None)#subprocess.DEVNULL)
  File "/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/home/username/Software/blender-3.4.0-linux-x64/blender', '--background', '-P', '/home/username/.local/lib/python3.6/site-packages/blend2bam/blend2gltf/blender28_script.py', '--', '/tmp/tmpexq93loi', '/home/username/Projects/CreatureGenerator', '/tmp', '/home/username/Projects/CreatureGenerator/armature_test_3.4.blend']' returned non-zero exit status 1.

Failed to convert all files
Germanunkol commented 1 year ago

Update: User "unwave" on Discord found a fix: The file had multiple Color Attributes, and one of them showed a "name collision" in blender. I never got this error in Blender 2.93. I don't know why it throws one in 3.4, but at least removing them or renaming the one with the collision fixes the issue (I don't need them any more, they were an intermediate step I needed before baking).

Feel free to close this, don't know if there's anything to do on the blend2bam side.