kcoley / gltf2usd

command-line utility for converting glTF 2.0 models to USD
MIT License
264 stars 38 forks source link

Strange Error Related to Color Texture #113

Closed enzyme69 closed 5 years ago

enzyme69 commented 5 years ago

I have tested different GLTF 2.0 exporter, I kept getting this error:

Traceback (most recent call last):
  File "gltf2usd.py", line 806, in <module>
    convert_to_usd(os.path.expanduser(args.gltf_file), os.path.abspath(os.path.expanduser(args.usd_file)), args.fps, args.scale, args.arkit, args.verbose, args.use_euler_rotation, args.optimize_textures)
  File "gltf2usd.py", line 754, in convert_to_usd
    usd = GLTF2USD(gltf_file=gltf_file, usd_file=usd_file, fps=fps, scale=scale, verbose=verbose, use_euler_rotation=use_euler_rotation, optimize_textures=optimize_textures)
  File "gltf2usd.py", line 74, in __init__
    self.convert()
  File "gltf2usd.py", line 725, in convert
    self.convert_nodes_to_xform()
  File "gltf2usd.py", line 90, in convert_nodes_to_xform
    self._convert_node_to_xform(node, parent_transform)
  File "gltf2usd.py", line 111, in _convert_node_to_xform
    usd_mesh = self._convert_mesh_to_xform(mesh, xformPrim, node)
  File "gltf2usd.py", line 267, in _convert_mesh_to_xform
    self._convert_primitive_to_mesh(primitive, usd_node, gltf_node, gltf_mesh)
  File "gltf2usd.py", line 313, in _convert_primitive_to_mesh
    colors = prim_var.CreatePrimvar('displayColor', Sdf.ValueTypeNames.Color3f, 'vertex').Set(attribute.get_data())
pxr.Tf.ErrorException: 
    Error in 'pxrInternal_v0_18__pxrReserved__::UsdStage::_SetValueImpl' at line 1522 in file /tmp/USD/pxr/usd/lib/usd/stage.cpp : 'Type mismatch for </root/Suzanne_0/primitive_0.primvars:displayColor>: expected 'VtArray<GfVec3f>', got '__1::vector<VtValue, __1::allocator<VtValue> >''

There is only one export by Daniel Stokes that seems to work.

Probably this is related to Image Textures RGBA or PBR: Roughness and Metalness should be grayscale? Not sure.

kcoley commented 5 years ago

Thanks @enzyme69 for flagging! I'll take a look at this later today.

enzyme69 commented 5 years ago

If you use Blender 2.8 Beta and their built in GLTF export, we also have same error.

enzyme69 commented 5 years ago

And Google Poly GLTF also giving error: https://poly.google.com/view/42Yqq-FuGfa

kcoley commented 5 years ago

@enzyme69 just merged a fix for this: https://github.com/kcoley/gltf2usd/pull/114

Note that vertex color alpha currently is not supported