kcoley / gltf2usd

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

Vertex Color GLTF #108

Closed enzyme69 closed 5 years ago

enzyme69 commented 5 years ago

Does the converter already respect the Vertex Color and RGBA? Or it's currently USDZ limitation and not yet possible?

I am testing a 3D Mesh from scan, it contains only PLY Vertex Color no UV. The ThreeJS can see the vertex color and display the result ok, then I exported as GLTF, but then when converting I am getting an 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/Scandy_Pro_2018_11_20_11_28_47_0/primitive_0.primvars:displayColor>: expected 'VtArray<GfVec3f>', got '__1::vector<VtValue, __1::allocator<VtValue> >''

Thanks!

enzyme69 commented 5 years ago
screen shot 2018-11-20 at 6 26 57 pm

To my surprise, the Vertex Color actually translated into USDZ and can be viewed on MacOS. But on iOS, it is only showing the default PBR material.

If I am not wrong, double-sided mesh also can work on USDZ, I can't remember but I did make USDZ that is shown as double sided. Maybe.

kcoley commented 5 years ago

Hi @enzyme69. Vertex colors are supported on export with this tool, though perhaps iOS is either expecting the primvar to be named a certain way or it is not supported somehow. It’s interesting that you see it working on Mac OS though.

Yes double sided meshes should also work on export.

enzyme69 commented 5 years ago

Ok maybe Vertex Color will simply work in the future :)

kcoley commented 5 years ago

@enzyme69 closing for now